PHP mail is not sending, but result is true

冷暖自知 提交于 2020-01-06 12:40:08

问题


i use phpmailer for sending emails. in one script, the code works fine, in other exaple, result is true, but no mail is delivered. error log is empty, what would you recommend to check? thanks

include_once '/var/www/xxxxxx.cz/web/php/phpmailer.php';
$to = 'dubcznic@gmail.com';
$to_name = '';
$from = 'robot@xxxxxx.cz';
$from_name = 'Robot';
$mail = new phpmailer();
$mail->CharSet = 'UTF-8';
$mail->From = $from;
$mail->FromName = $from_name;
$mail->AddAddress($to, $to_name);  // Add a recipient
$mail->AddCC('nabytek-safr@xxxx.cz');
$mail->WordWrap = 50;     // Set word wrap to 50 characters
$mail->IsHTML(true);      // Set email format to HTML
$mail->Subject = 'Import Robot Autronic';
$mail->Body = 'xxx';
$mail->AltBody = str_replace("<br />", "\n", 'xxx');
if (!$mail->Send())
{
    echo 'Mail Error: ' . $mail->ErrorInfo;
    exit;
}
else
{
    echo 'OK';
}

die();

回答1:


Check what text you are sending. It could be that your results are being filtered out and put in a Spam folder. Sometimes a mail with 'test' in the title could be sent right to Spam.




回答2:


It is impossible to verify that an email was delivered with PHP.

Check your mail server log (usually /var/log/mail) to see if the email was sent.

Send a BCC to an email address that you know has no spam filters.




回答3:


You can validate real emails with Telnet and MX records. See this answers https://stackoverflow.com/a/17332773/468891




回答4:


First, check your spam, if you haven't already.

Second, change your SMTP settings to that of gmails, put your gmail log in and password and try. If a mail fails to deliver you'll get an delivery- failure notification with possible causes of failure, which helps a lot. A delivery failure can also happen when no error is displayed in PHP. This always helps me.



来源:https://stackoverflow.com/questions/14613234/php-mail-is-not-sending-but-result-is-true

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!