Php 外部SMTP发送服务器->客户端:250确定:排队为CA053776D18邮件未发送

Php 外部SMTP发送服务器->客户端:250确定:排队为CA053776D18邮件未发送,php,email,smtp,external,phpmailer,Php,Email,Smtp,External,Phpmailer,我有一个html表单,它使用php将表单数据通过电子邮件发送到外部邮件服务器。我的代码已更改以保护innoicent: <?php //$ckNotify = $_POST['ckNotify']; $ckNotify = isset($_POST['ckNotify']) && $_POST['ckNotify'] ? "Please sign me up for Email Notifications" : "NO"; $ckUnsubscribe = isset(

我有一个html表单,它使用php将表单数据通过电子邮件发送到外部邮件服务器。我的代码已更改以保护innoicent:

<?php

//$ckNotify = $_POST['ckNotify'];
$ckNotify = isset($_POST['ckNotify']) && $_POST['ckNotify'] ? "Please sign me up for Email Notifications" : "NO";

$ckUnsubscribe = isset($_POST['ckUnsubscribe']) && $_POST['ckUnsubscribe'] ? "Plese unsubscribe me from Email Notifications" : "Does Not Apply to this instance";

$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];

if (!empty($_POST)) //Validate first
{
    if (empty($name) || empty($visitor_email)) {
        echo "Name and email are mandatory!";
        exit;
    }
}

if (IsInjected($visitor_email)) {
    echo "Bad email value!";
    exit;
}

date_default_timezone_set('America/Chicago');

require_once 'PHPMailerAutoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
// 3 = verbose messages
$mail->SMTPDebug = 3;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "74.84.86.134";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 25;
//Whether to use SMTP authentication
$mail->SMTPAuth = false;
//Set who the message is to be sent from
$mail->setFrom('miket@extsmtp.net', 'Mike Tolliver');
//Set an alternative reply-to address
$mail->addReplyTo('miket@extsmtp.net', 'Mike Tolliver');
//Set who the message is to be sent to
$mail->addAddress('miket@extsmtp.net', 'Mike Tolliver');
//Set the subject line
$mail->Subject = 'New Form Submission';
//Get message contents from form and place in body of email as basic plain-test
$body = "Email Notifications: $ckNotify
UnSubscribe User: $ckUnsubscribe
Name: $name
Email: $visitor_email
Message: $message";
$mail->MsgHTML($body);
//Replace the plain text body with one created manually
//$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

//done - redirect to thank-you page if no errors
if (!$mail->Send()) {
    header('Location: ThankYou.html');
//echo "Mail Sent Successfully";
} else {
    echo "Mail Not Sent";
}

// Function to validate against any email injection attempts
function IsInjected($str)
{
    $injections = array(
        '(\n+)',
        '(\r+)',
        '(\t+)',
        '(%0A+)',
        '(%0D+)',
        '(%08+)',
        '(%09+)'
    );
    $inject = join('|', $injections);
    $inject = "/$inject/i";
    if (preg_match($inject, $str)) {
        return true;
    } else {
        return false;
    }
}
但我在提交表单并进入php页面后得到了以下输出:

    2015-02-03 23:18:21 Connection: opening to 74.84.86.134:25, t=10, opt=array ( ) 
2015-02-03 23:18:21 Connection: opened 
2015-02-03 23:18:21 SERVER -> CLIENT: 220 barracuda.platinum-corp.com ESMTP (b35451cd44f584ec6f962de7068c7240) 
2015-02-03 23:18:21 CLIENT -> SERVER: EHLO www.extsmtp.net 
2015-02-03 23:18:21 SERVER -> CLIENT: 250-barracuda.platinum-corp.com Hello www.extsmtp.net [173.0.129.93], pleased to meet you 250-SIZE 100000000 250-STARTTLS 250-PIPELINING 250-8BITMIME 250 HELP 
2015-02-03 23:18:21 CLIENT -> SERVER: MAIL FROM: 
2015-02-03 23:18:21 SERVER -> CLIENT: 250 Sender OK 
2015-02-03 23:18:21 CLIENT -> SERVER: RCPT TO: 
2015-02-03 23:18:21 SERVER -> CLIENT: 250 Recipient OK 
2015-02-03 23:18:21 CLIENT -> SERVER: DATA 
2015-02-03 23:18:21 SERVER -> CLIENT: 354 Start mail input; end with . 
2015-02-03 23:18:21 CLIENT -> SERVER: Date: Tue, 3 Feb 2015 17:18:21 -0600 
2015-02-03 23:18:21 CLIENT -> SERVER: Return-Path: miket@extsmtp.net 
2015-02-03 23:18:21 CLIENT -> SERVER: To: Mike Tolliver 
2015-02-03 23:18:21 CLIENT -> SERVER: From: Mike Tolliver 
2015-02-03 23:18:21 CLIENT -> SERVER: Reply-to: Mike Tolliver 
2015-02-03 23:18:21 CLIENT -> SERVER: Subject: New Form Submission 
2015-02-03 23:18:21 CLIENT -> SERVER: Message-ID: <718f56184800b47dd0a9327e8003f4f1@www.extsmtp.net> 
2015-02-03 23:18:21 CLIENT -> SERVER: X-Priority: 3 
2015-02-03 23:18:21 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2 (http://code.google.com/a/apache-extras.org/p/phpmailer/) 
2015-02-03 23:18:21 CLIENT -> SERVER: MIME-Version: 1.0 
2015-02-03 23:18:21 CLIENT -> SERVER: Content-Type: multipart/alternative; 
2015-02-03 23:18:21 CLIENT -> SERVER: boundary="b1_718f56184800b47dd0a9327e8003f4f1" 
2015-02-03 23:18:21 CLIENT -> SERVER: 
2015-02-03 23:18:21 CLIENT -> SERVER: 
2015-02-03 23:18:21 CLIENT -> SERVER: --b1_718f56184800b47dd0a9327e8003f4f1 
2015-02-03 23:18:21 CLIENT -> SERVER: Content-Type: text/plain; charset="iso-8859-1" 
2015-02-03 23:18:21 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit 
2015-02-03 23:18:21 CLIENT -> SERVER: 
2015-02-03 23:18:21 CLIENT -> SERVER: To view the message, please use an HTML compatible email viewer! 
2015-02-03 23:18:21 CLIENT -> SERVER: 
2015-02-03 23:18:21 CLIENT -> SERVER: 
2015-02-03 23:18:21 CLIENT -> SERVER: --b1_718f56184800b47dd0a9327e8003f4f1 
2015-02-03 23:18:21 CLIENT -> SERVER: Content-Type: text/html; charset="iso-8859-1" 
2015-02-03 23:18:21 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit 
2015-02-03 23:18:21 CLIENT -> SERVER: 
2015-02-03 23:18:21 CLIENT -> SERVER: Email Notifications: Please sign me up for Email Notifications 
2015-02-03 23:18:21 CLIENT -> SERVER: UnSubscribe User: Does Not Apply to this instance 
2015-02-03 23:18:21 CLIENT -> SERVER: Name: Joyce Small 
2015-02-03 23:18:21 CLIENT -> SERVER: Email: jsmall@somewhere.net 
2015-02-03 23:18:21 CLIENT -> SERVER: Message: Test message using external smtp settings 
2015-02-03 23:18:21 CLIENT -> SERVER: 2015-02-03 23:18:21   CLIENT -> SERVER: 
2015-02-03 23:18:21 CLIENT -> SERVER: 
2015-02-03 23:18:21 CLIENT -> SERVER: --b1_718f56184800b47dd0a9327e8003f4f1-- 
2015-02-03 23:18:21 CLIENT -> SERVER: 
2015-02-03 23:18:21 CLIENT -> SERVER: . 
2015-02-03 23:18:21 SERVER -> CLIENT: 250 Ok: queued as CA053776D18 Mail Not Sent

看起来一切对我来说都很好,但话说回来,我是php的新手,除了最后没有发送的邮件。有人知道为什么邮件没有被发送吗?基于我有限的知识,似乎外部smtp服务器没有中继-但我知道什么。谢谢你的帮助

您正试图通过74.84.86.134中继消息的远程主机将转到spamfilter.coralville.platinum-corp.com。我假设这是您试图发送到的域的MX,否则您可能不会在SMTP会话中取得您所取得的进展。尽管如此,这个远程主机似乎正在接受来自PHP应用程序的消息,但在收到消息后,会决定您不是合法的邮件发送者,因此会出现“邮件未发送”消息

若要检查应用程序发送的邮件有一个明显的问题,可能会导致其他邮件服务器认为它是垃圾邮件,请尝试从应用程序发送邮件进行检查-auth@verifier.port25.com. 这项服务将进行一系列检查,您将收到一份包含大量信息的报告,例如服务器的DNS转发和反转是否正确,服务器的IP是否在黑名单上,如果您的SPF记录有问题,等等


或者,一个更简单的解决方案可能是通过一个众所周知的SMTP中继(如SMTP.gmail.com、SendGrid等)来中继这些传出消息。

我认为这不是真的。如果它不喜欢发件人,它应该拒绝早期的邮件服务器不要故意浪费自己的资源,即使它们是蜜罐,如果它出于策略原因拒绝,它应该返回450或550代码。从目前的情况来看,邮件服务器似乎被设置为黑名单邮件,原因不详。不,邮件服务器接受一封完整的邮件并发出250个OK,然后在事后默默地丢弃邮件,认为这是垃圾邮件,这种情况并不少见。事实上,许多垃圾邮件过滤器在邮件正文上应用贝叶斯分析,这需要接收整个邮件。当然,但垃圾邮件过滤器在此基础上接受和放弃而不是拒绝垃圾邮件是不寻常的,因为它不会阻止未来的垃圾邮件。垃圾邮件过滤非常昂贵,因此您希望尽可能少地使用它。这就是postscreen这样的东西存在的原因。无论如何,我们需要查看OP的邮件服务器日志和配置,以诊断是否发生了这种情况,或者它是否刚刚损坏。您需要查看邮件服务器日志和本地配置。它看起来像是将所有消息或至少来自您的消息设置为黑洞,这在测试配置中相当常见。啊,有一件事-您使用的是非常旧版本的PHPMailer。另外,为什么要编写IsInjected函数-PHPMailer已经为您处理了这个问题。