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条)

报告相同问题?

悬赏问题

  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题