我想设置自己的 SMTP 服务器(仅发送邮件)来处理来自我的 Web 应用程序的所有通知邮件等
dpkg-reconfigure exim4-config
Type: internet site
FQDN: smtp.mydomain.com
SMTP listener: 127.0.0.1; ::1
Mail destinations: Debian-Buster10; localhost
Relay: (empty)
Follow up screen relay: (empty)
DNS queries minimal: No
Delivery method: Maildir in home dir
Split conf files: No
我通过 PHPmailer 发送邮件..它已发送但从未收到?
php邮件程序
try{
$mail = new PHPMailer(true);
$mail->SMTPDebug = 1;
$mail->SMTPSecure = 'tls';
$mail->SMTPAutoTLS = false;
$mail->SMTPAuth = true;
$mail->SMTPOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
];
//$mail->CharSet = 'UTF-8';
$mail->IsSMTP();
$mail->Port = 25;
$mail->Host = '127.0.0.1';
$mail->Username = 'user';
$mail->Password = 'pass';
$mail->AddAddress('[email protected]', 'me');
$mail->From = '[email protected]';
$mail->FromName = 'me';
$mail->Subject = 'test mail';
$mail->Body = 'hello world';
$mail->Send();
}
catch(phpmailerException $e){
echo "err: ".$e->getMessage()."\n";
}
phpmailer SMTP 调试输出
2019-09-03 06:59:35 CLIENT -> SERVER: EHLO Test-Athlon-3700-2gb
2019-09-03 06:59:35 CLIENT -> SERVER: STARTTLS
2019-09-03 06:59:35 CLIENT -> SERVER: EHLO Test-Athlon-3700-2gb
2019-09-03 06:59:35 CLIENT -> SERVER: AUTH PLAIN
2019-09-03 06:59:35 CLIENT -> SERVER: AGR5bmFjY291bnQAVWF4ZDIwMDEr
2019-09-03 06:59:35 CLIENT -> SERVER: MAIL FROM:<[email protected]>
2019-09-03 06:59:35 CLIENT -> SERVER: RCPT TO:<[email protected]>
2019-09-03 06:59:35 CLIENT -> SERVER: DATA
2019-09-03 06:59:35 CLIENT -> SERVER: Date: Tue, 3 Sep 2019 06:59:35 +0000
2019-09-03 06:59:35 CLIENT -> SERVER: To: me <[email protected]>
2019-09-03 06:59:35 CLIENT -> SERVER: From: me <[email protected]>
2019-09-03 06:59:35 CLIENT -> SERVER: Subject: test mail
2019-09-03 06:59:35 CLIENT -> SERVER: Message-ID: <6ade75e609c3a3e595f324172e0d08eb@Test-Athlon-3700-2gb>
2019-09-03 06:59:35 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.14 (https://github.com/PHPMailer/PHPMailer)
2019-09-03 06:59:35 CLIENT -> SERVER: MIME-Version: 1.0
2019-09-03 06:59:35 CLIENT -> SERVER: Content-Type: text/plain; charset=iso-8859-1
2019-09-03 06:59:35 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2019-09-03 06:59:35 CLIENT -> SERVER:
2019-09-03 06:59:35 CLIENT -> SERVER: hello world
2019-09-03 06:59:35 CLIENT -> SERVER:
2019-09-03 06:59:35 CLIENT -> SERVER: .
2019-09-03 06:59:36 CLIENT -> SERVER: QUIT
答案1
您可能没有在 Exim 中启用身份验证(它已被禁用),但您在 phpmailer 中需要它。
从 phpmailer 中删除 TLS 和身份验证的要求。