Click to See Complete Forum and Search --> : mail( function, unstable);
august
03-21-2006, 04:51 AM
Why is it that first, today, when I used the mail() function an email was sent to the supplied adress several times in a row and it worked. But then when I changed the email adress to be sent to, it didn't work. Subsequently the mail wasn't submitted to the first adress either, which was used at first and worked.
??? :confused: :confused:
Then, is the mail() function unstable or what else could possibly cause this unpredictable behavior? Could it be that mail() has a brain and a will of its own, and only sends out emails if it wants to? Or, has a bias toward some email adresses and against others?
gayatri
03-21-2006, 05:38 AM
if u can post code here, it would be easy to fix up the bug
NogDog
03-21-2006, 11:15 AM
mail() does some internal validation, then if it passes it sends it off to the hosts sendmail program (or other designated mailer). If that sendmail program accepts the data from mail() without complaining, and then subsequently runs into some problem such as the receiving mail program rejecting the email due to some malformed or missing header, your PHP script will never know about it. You would then have to search through the sendmail logs, email messages on the postmaster account, etc. to find any hints as to what the problem was.
bokeh
03-21-2006, 02:39 PM
mail() does some internal validation, then if it passes it sends it off to the hosts sendmail program (or other designated mailer).Is that a Linux behaviour?
august
03-21-2006, 10:52 PM
Hi. Here's the piece of code that actually worked for the first half part of the day, and failed the second half. And still doesn't work. The point is that no code has been changed. The only differencies have been the changing email adresses.
$to=$Email;
$subject="Another one!";
$msg=$Comments;
if(mail($to,$subject,$msg)) echo "An email has been sent to $to."; else echo "it didn't work"; ?>
Is there some way to stablizie this function. For instance, what do websites like PayPal and eBay and amazon use for their contact forms?
If you want to be certain that an email from PHP arrives at the intended destination what should you do? Obviously if there's no amount of guarantee that the emails from mail() reach their targets, it's got to be a rather useless function wouldn't you agree? Is there some "better" function you can use for emails then?
:D
NogDog
03-21-2006, 11:02 PM
You may need to add a from email address to the additional headers parameter. (Most mail hosts will reject a message without a from address.) I normally include the From, Reply-to, and Mailer additional headers as per Example 2 on http://www.php.net/manual/en/function.mail.php