Error On Sending Email
A few days ago, i can send email via mail() function on my server. But n开发者_开发问答ow, mails doens't sending . There isn't anything at error log. I don't get any error. I don't know, why emails not sending.
What can i do? How can i solve this?
EDIT Now i get all emails (about 18 mails :) ) . Why mails delayed?
PHP's mailer function does not actually deliver the mail. It simply hands it off to an SMTP server for that. Whether or not it actually gets delivered is not considered by mail()
, it's just concerned with the hand-off.
If the SMTP server accepts it, then mail()
will return true and pretend everything worked fine. The SMTP server may delete the mail, send it to the wrong place, route it through a tangle of other SMTP servers causing the mail to be delayed by a year, etc..., but mail()
will still have said everything's fine.
The place to look for the cause of this is your mail server's own log. If there was a delivery problem, there'd be a list of each delivery attempt in there somewhere.
Have you tried doing this?
The problem seems to be that PHP use the ini directive sendmail_from to set the from email address in the SMTP protocol. If this is not correctly set, or if it does not match the from header in the email headers, the email is caught by spam protection software. The simplest solution is to set the directive during execution:
ini_set("sendmail_from", $email_from);
$headers = "From: $email_from";
mail($to, $subject, $message, $headers);
Ok, now i have got 18 mails together. I don't know, why mails are delaying.
Maybe your receiving mailserver implemented greylisting (http://en.wikipedia.org/wiki/Greylisting) ...
Do you have access to the mailqueue or maillog of your webserver? In that case you can search for delayed or bounced messages there.
精彩评论