我需要你的帮助。 实际上,只有从服务器执行脚本后,发送给收件人的电子邮件才会到达。 如果脚本是从远程客户端执行的,则连接到SMTP服务器没有错误,但是电子邮件永远不会到达。仅在法语smtp(smtp.orange.fr)中存在此问题 在我用来测试的脚本下面找到:
<?php
include('PHPMailer_v5.2.16/class.phpmailer.php');
include('PHPMailer_v5.2.16/class.smtp.php');
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.orange.fr'; // Specify main (and backup SMTP) servers (sÈparÈs par un point virgule)
$mail->SMTPAuth = false;
$mail->SMTPAutoTLS = false;
//$mail->SMTPAuth = false; // Enable SMTP authentication
//$mail->SMTPAuth = true;
$mail->Username = '';
$mail->Password = ''; // SMTP password
//$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
//$mail->SMTPSecure = 'tls'; //provoque une erreur de connexion
//$mail->SMTPSecure = 'ssl'; //provoque une erreur "SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting"
$mail->Port = 25; // TCP port to connect to
//$mail->Port = 465; // TCP port to connect to
$mail->setLanguage('fr', 'language/');
$mail->CharSet ='utf-8';
$mail->setFrom('exemplefrom@laposte.net', 'Exp');
$mail->addAddress('exempleto@laposte.net', 'Joe User');// Add a recipient
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Sujet du mail';
$mail->Body = 'corps du mail <b>en gras!</b>';
//OE
$mail->WordWrap = 0;
$mail->ContentType = 'text/html';
$mail->Encoding = '8bit';
$mail->send();
echo 'Le message a été envoye';
} catch (Exception $e) {
echo 'Message could not be sent. ';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
?>
在两种情况下,从服务器或客户端进行的调试都是相同的:
2020-11-03 21:06:07 SERVER -> CLIENT: 220 mwinf5d15 ME ESMTP server ready
2020-11-03 21:06:07 CLIENT -> SERVER: EHLO 127.0.0.1
2020-11-03 21:06:07 SERVER -> CLIENT: 250-mwinf5d15 hello [86.245.192.50], pleased to meet you
250-HELP
250-AUTH LOGIN PLAIN
250-SIZE 44000000
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 OK
2020-11-03 21:06:07 CLIENT -> SERVER: MAIL FROM:
2020-11-03 21:06:07 SERVER -> CLIENT: 250 2.1.0 sender ok
2020-11-03 21:06:07 CLIENT -> SERVER: RCPT TO:
2020-11-03 21:06:07 SERVER -> CLIENT: 250 2.1.5 recipient ok
2020-11-03 21:06:07 CLIENT -> SERVER: DATA
2020-11-03 21:06:07 SERVER -> CLIENT: 354 enter mail, end with "." on a line by itself
2020-11-03 21:06:07 CLIENT -> SERVER: Date: Tue, 3 Nov 2020 21:06:07 +0000
2020-11-03 21:06:07 CLIENT -> SERVER: To: Joe User
2020-11-03 21:06:07 CLIENT -> SERVER: From: Exp
2020-11-03 21:06:07 CLIENT -> SERVER: Subject: Sujet du mail
2020-11-03 21:06:07 CLIENT -> SERVER: Message-ID: <2671dcaa1642a1c676ea766b38c3ba5a@127.0.0.1>
2020-11-03 21:06:07 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.16 (https://github.com/PHPMailer/PHPMailer)
2020-11-03 21:06:07 CLIENT -> SERVER: MIME-Version: 1.0
2020-11-03 21:06:07 CLIENT -> SERVER: Content-Type: text/html; charset=utf-8
2020-11-03 21:06:07 CLIENT -> SERVER:
2020-11-03 21:06:07 CLIENT -> SERVER: corps du mail en gras!
2020-11-03 21:06:07 CLIENT -> SERVER:
2020-11-03 21:06:07 CLIENT -> SERVER: .
2020-11-03 21:06:07 SERVER -> CLIENT: 250 2.0.0 nx5z2300P15i9bJ03x5z8R mail accepted for delivery
2020-11-03 21:06:07 CLIENT -> SERVER: QUIT
2020-11-03 21:06:07 SERVER -> CLIENT: 221 2.0.0 mwinf5d15 ME closing connection Le message a été envoye
那么您能帮我解决这个问题吗? 最好的问候
答案 0 :(得分:1)
首先,您正在运行真正的PHPMailer旧版本,其中包含几个主要的安全漏洞,因此在进行其他操作之前,请upgrade to the latest version。
接下来,请注意,邮件服务器成功接受了邮件:
已接受250 2.0.0 nx5z2300P15i9bJ03x5z8R邮件的发送
因此从现在开始,您的脚本不再对消息发生的事情负责。
对此的最可能的解释是该邮件已发送,并且隐藏在您的垃圾邮件文件夹中。
如果邮件退回,您应该会收到一条消息,告知您已发送到您的信封发件人地址,该地址将是您在setFrom()
中设置的地址。
Orange也有可能只是在丢失您的信息。他们的电子邮件服务器配置确实很糟糕,例如,他们甚至没有在应该这样做的端口上提供TLS,并且允许进行身份验证而无需加密:
telnet smtp.orange.fr 587 1 ↵ 11142 10:31:25
Trying 193.252.22.84...
Connected to smtp.orange.fr.
Escape character is '^]'.
220 mwinf5d29 ME ESMTP server ready
EHLO localhost
250-mwinf5d29 hello [x.x.x.x], pleased to meet you
250-HELP
250-AUTH LOGIN PLAIN
250-SIZE 44000000
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 OK
这意味着可以诱骗客户端连接到伪造的服务器,任何可以看到您的Internet流量的人都容易拦截凭据,并且该服务器似乎有可能被用作垃圾邮件网关。对于如此受欢迎的服务,这真是太糟糕了。
我会向Orange提出支持请求,以寻求他们的帮助。这个问题与您的脚本无关。