douxuanpa8298 2018-04-24 09:25
浏览 59
已采纳

PHPMailer在某些情况下不起作用

I am sending mail with PHPmailer. The mail I send is working on Gmail. But it does not work in the account on mail.com. Does anyone know why? The result seems to be successful. But mail is not coming.

Example not working: developer@chef.net

Note: I'm using the same settings. My mail server on another server.

If the code I'm using is :

$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPAuth = true; // authentication enabled
$mail->SetLanguage("tr", "class/language");
$mail->CharSet    = "utf-8";
$mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for GMail
$mail->Host       = "example";
$mail->Port       = 25; // or 465
$mail->IsHTML(true);
$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);
$mail->Username    = "example@example.com";
$mail->Password    = "example";
$mail->SetFrom($To[1], $To[0]);
$mail->Subject = 'example';

$mail->Body = 'example';
$mail->AddAddress($From[1], $From[0]);

if ($mail->Send()) {
    echo 'success';
} else {
    echo $mail->ErrorInfo;
}

I was also redirected to my server CloudFlare.

PHPMailer Logs Output:

2018-04-24 11:24:49 SERVER -> CLIENT: 220 centos.controlsunucu.com ESMTP Postfix
2018-04-24 11:24:49 CLIENT -> SERVER: EHLO oxyn.org
2018-04-24 11:24:49 SERVER -> CLIENT: 250-centos.controlsunucu.com
                                      250-PIPELINING
                                      250-SIZE 10240000
                                      250-ETRN
                                      250-STARTTLS
                                      250-AUTH DIGEST-MD5 CRAM-MD5 PLAIN LOGIN
                                      250-ENHANCEDSTATUSCODES
                                      250-8BITMIME
                                      250 DSN
2018-04-24 11:24:49 CLIENT -> SERVER: STARTTLS
2018-04-24 11:24:49 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2018-04-24 11:24:49 CLIENT -> SERVER: EHLO oxyn.org
2018-04-24 11:24:49 SERVER -> CLIENT: 250-centos.controlsunucu.com
                                      250-PIPELINING
                                      250-SIZE 10240000
                                      250-ETRN
                                      250-AUTH DIGEST-MD5 CRAM-MD5 PLAIN LOGIN
                                      250-ENHANCEDSTATUSCODES
                                      250-8BITMIME
                                      250 DSN
2018-04-24 11:24:49 CLIENT -> SERVER: AUTH CRAM-MD5
2018-04-24 11:24:49 SERVER -> CLIENT: 334 PDg0NDE4Mjc5NS4xNDYxOTU4NkBjZW50b3MuY29udHJvbHN1bnVjdS5jb20+
2018-04-24 11:24:49 CLIENT -> SERVER: aW5mb0BkaXN0aWxlaWNraS5jb20gYWQ1MmQ2YjZjZTkzZTE3OTMzZDU5ZGNmNzZmNTJlYWY=
2018-04-24 11:24:49 SERVER -> CLIENT: 235 2.7.0 Authentication successful
2018-04-24 11:24:49 CLIENT -> SERVER: MAIL FROM:<apawebit@gmail.com>
2018-04-24 11:24:49 SERVER -> CLIENT: 250 2.1.0 Ok
2018-04-24 11:24:49 CLIENT -> SERVER: RCPT TO:<developer@chef.net>
2018-04-24 11:24:49 SERVER -> CLIENT: 250 2.1.5 Ok
2018-04-24 11:24:49 CLIENT -> SERVER: DATA
2018-04-24 11:24:49 SERVER -> CLIENT: 354 End data with <CR><LF>.<CR><LF>
2018-04-24 11:24:49 CLIENT -> SERVER: Date: Tue, 24 Apr 2018 14:24:49 +0300
2018-04-24 11:24:49 CLIENT -> SERVER: To: =?utf-8?Q?=C3=96zg=C3=BCr_Can_KARAG=C3=96Z?= <developer@chef.net>
2018-04-24 11:24:49 CLIENT -> SERVER: From: =?utf-8?Q?=C3=96zg=C3=BCr_Can_KARAG=C3=96Z?= <apawebit@gmail.com>
2018-04-24 11:24:49 CLIENT -> SERVER: Subject: Example
2018-04-24 11:24:49 CLIENT -> SERVER: Message-ID: <75ef49ca7263c41f42336be38def81f9@oxyn.org>
2018-04-24 11:24:49 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.22 (https://github.com/PHPMailer/PHPMailer)
2018-04-24 11:24:49 CLIENT -> SERVER: MIME-Version: 1.0
2018-04-24 11:24:49 CLIENT -> SERVER: Content-Type: text/html; charset=utf-8
2018-04-24 11:24:49 CLIENT -> SERVER:
2018-04-24 11:24:49 CLIENT -> SERVER: Example
2018-04-24 11:24:49 CLIENT -> SERVER:
2018-04-24 11:24:49 CLIENT -> SERVER: .
2018-04-24 11:24:50 SERVER -> CLIENT: 250 2.0.0 Ok: queued as 918D133B8F
2018-04-24 11:24:50 CLIENT -> SERVER: QUIT
2018-04-24 11:24:50 SERVER -> CLIENT: 221 2.0.0 Bye
  • 写回答

2条回答 默认 最新

  • doujiao0110 2018-04-24 10:57
    关注

    Set $mail->SMTPDebug = 2 to see the SMTP conversation, so you can be absolutely sure messages are being accepted and that you're not missing any interesting responses from the server. Beyond that, check your spam folder, and if your ISP is black-holing your messages, complain to them.

    Your use of $From and $To looks to be the wrong way around, and it's not possible to tell if they are using user-supplied values - allowing a user to supply an address that you use as a From address is a sure way to get your email blocked or spam filtered since it's forgery and will break SPF and DMARC checks.

    On the certificate front, that your site is using Cloudflare has nothing to do with the certificates used for mail.com's mail servers. You should only disable certificate checks if you have a very specific reason for doing so - "because it makes it work" is not a valid reason.

    Update:

    You're sending from a gmail address without sending through gmail - that will fail SPF checks. If you want to send From a gmail address, you must send through gmail, not your ISP.

    Unlikely to be a factor here, but you're using an old version of PHPMailer - upgrade to 6.0.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?