Jump to content

what is the problem?


pluginbaby

Recommended Posts

[code]<?php

$to      = '[email protected]';
$subject = 'test';
$message = 'hello';

mail($to, $subject, $message);
echo "email send";
?>[/code]

I used this piece of code to test that an email would be send to my if I run it.
I run it and it gives me the message: "email send". When I look in my inbox there is nothing there.

I checked if the email address is correct, and it is.
I waited 24 hours for the email to arrive, and still nothing.
I have send the email more then 1 time, so it should be there...

What can the problem be then?
Link to comment
https://forums.phpfreaks.com/topic/18028-what-is-the-problem/
Share on other sites

Most email programs expect to see a "From:" header or they will toss the email down the bit bucket. Add at least the fourth parameter to the mail() function:

[code]<?php
$to      = '[email protected]';
$subject = 'test';
$message = 'hello';
$headers = 'From: [email protected]';

if (mail($to, $subject, $message,$headers)) echo "email send";
?>[/code]
Note: A successful return from the mail() function just means that your message was queued to be sent, not that it was sent successfully.

Also, hotmail.com has been notorious for filtering out email messages and not telling about it. If you have another email address you can use to test with, try that one.

Ken
Link to comment
https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77214
Share on other sites

Okay, I tried with the "From ..." thing.

Still got nothing in my inbox...

Anyway, I want to use this for a registration. You register and an activation is send to your email address. If this doesn't work on hotmail, there is no point of building that, since a lot of people I know only have hotmail. :o
Link to comment
https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77215
Share on other sites

If you are using a shared host on a Linux (UNIX) box, you probably also need to use the fifth parameter to the mail() function. This parameter sets the "Return-path:" header. If the domain in that header doesn't match the domain of the address in the "From:" header hotmail.com will toss the email.

The fifth parameter looks like:
[code]<?php $p5  = '-f [email protected]'; ?>[/code] and is used like [code]<?php mail($to,$subject,$msg,$headers,$p5); ?>[/code]

Ken
Link to comment
https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77225
Share on other sites

okay, I have added the 5th parameter:

[code]<?php
$to      = '[email protected]';
$subject = 'test';
$message = 'hello';
$headers = 'From: [email protected]';
$p5  = '-f [email protected]';

if (mail($to,$subject,$msg,$headers,$p5)) echo "email send";
?>[/code]

But when I runned it, I got this error:

[quote]Warning: mail() [function.mail]: SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE MODE. in /srv/www/htdocs/web34/html/test.php on line 8[/quote]

What can I do about that then?
Link to comment
https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77229
Share on other sites

here is another example of a simple one. You may want to read up on the use of the headers in the mail.

[code=php:0]mail($to, $subject, $message, "From: You<[email protected]>\nX-Mailer: PHP/" . phpversion());[/code]

Give this a try

Hope this helps,
Tom
Link to comment
https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77231
Share on other sites

Not sure. I would contact my host if I were you. Do you know what mail server they are using? If not I would send them an email with your issue.

This script that I posted is a functional [code=php:0]mail();[/code] format. Is is very basic but should work.

Good luck,
Tom
Link to comment
https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77241
Share on other sites

well, it does work. But not with a @hotmail adres.

When I send it to my [email protected] it works. But when I send it at my [email protected] it doesn't work. What I want is that it works also on the @hotmail.com email address, cause the site where I want to use it for has a lot @hotmail.com email addresses, and if they can't recieve the email, there is no use of me creating this ;)

I hope you understand my problem and there is a way of fixing it...
Link to comment
https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77242
Share on other sites

Ok I tried this and it worked

[code=php:0]if ($ccaddress=="" || $ccaddress==" "){
$header="From: $knownsender";

}else{
$header .="From: $knownsender\r\n";
$header .=" Cc: $ccaddress";
}
// $header.="Bcc: $bcaddress";

if (@mail($mailtos, $subject, $message, $header)){
echo "Your Email has been sent.";
}else{
echo "There was an error sending your Email";
}[/code]

$knownsender is an email address that is known to the server. I never thought to use this but it works just fine.

Give it a try.

Link to comment
https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77247
Share on other sites

Hmm, I must be doing something wrong then:

[code]<?php
$mailtos = "[email protected]";
$subject = "test";
$message = "this is a testingmessage";
$knownsender = "[email protected]";

if ($ccaddress=="" || $ccaddress==" "){
$header="From: $knownsender";
}else{
$header .="From: $knownsender\r\n";
$header .=" Cc: $ccaddress";
}
// $header.="Bcc: $bcaddress";

if (@mail($mailtos, $subject, $message, $header)){
echo "Your Email has been sent.";
}else{
echo "There was an error sending your Email";
}
?>[/code]

This is the exact code I executed, but I didn't got any emails at my hotmail account, I was wondering, is the "$knownsender" correct?
Link to comment
https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77252
Share on other sites

I did it without the 5th parameter. It works without it to.

I set up an email address at my domain called: automailer@....
I also changed the subject of my email, maybe MSN sees "test" as a spam subject.

Anyway, now it finally arrived. I tested a couple of times and it keeps working.

Thank you all of you for helping me out on this one ;D
Link to comment
https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77281
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.