当我运行以下 PHP 代码时,出现错误。
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = SMTP::DEBUG_SERVER; // debug
$mail->Host = 'localhost';
$mail->Port = 25;
$mail->SMTPAuth = true;
$mail->Username = $uname;
$mail->Password = $pw;
$mail->CharSet = PHPMailer::CHARSET_UTF8;
$mail->setFrom('no-reply@example.com', 'website registration');
$mail->addAddress($cleaned_email);
$mail->Subject = 'Please verify your account';
$msg = '[registration text...]'
$msg = wordwrap($msg, 70);
$mail->Body = $msg;
if (!$mail->send()) {
echo $mail->ErrorInfo;
exit();
} else {
[... add user to db, etc...]
}
邮件似乎已发送。PHPMailer 不会生成任何错误,并且数据库代码会运行。
这是在 mail.log 中生成的错误。
Aug 22 11:47:06 server postfix/smtp[8339]: 079AB1F909: to=<outsider-at-anydomain.com>, relay=mail.brighthouse.com[47.43.26.56]:25, delay=5.7, delays=0.06/0.02/0.31/5.3, dsn=2.0.0, status=sent (250 2.0.0 <user-at-example.com> sender rejected. Please see understanding-email-error-codes for more information.)
我尝试将发送地址更改为我在 PHP 代码中进行身份验证的用户。
我尝试将带有匹配哈希表的 smtpd_sender_login_maps 参数添加到我的后缀配置中,以将无回复地址映射到我进行身份验证的用户,但它会将其作为未使用的参数忽略。
后缀配置:
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Raspbian)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2
呼唤远方
噜噜哒