错误,连接断开

时间:2016-10-17 13:02:58

标签: php phpmailer

出于某种原因,我们用来发送电子邮件的其中一个网络表格突然停止工作。出现以下错误:

2016-10-17 07:42:15 Connection: opening to smtp.example.org.uk:25, timeout=300, options=array ( )
2016-10-17 07:42:15 Connection: opened 
2016-10-17 07:42:15 SERVER -> CLIENT: 220 smtp-ca.example.org.uk ESMTP
2016-10-17 07:42:15 CLIENT -> SERVER: EHLO forms.example.org
2016-10-17 07:42:15 SERVER -> CLIENT: 250-smtp-ca.example.org.uk 250-8BITMIME 250-SIZE 41943040 250 STARTTLS
2016-10-17 07:42:15 CLIENT -> SERVER: STARTTLS
2016-10-17 07:42:15 SERVER -> CLIENT: 220 Go ahead with TLS 
2016-10-17 07:42:16 SMTP Error: Could not connect to SMTP host.
2016-10-17 07:42:16 CLIENT -> SERVER: QUIT 
2016-10-17 07:42:16 SERVER -> CLIENT: 5Ul2̔4Oi6
2016-10-17 07:42:16 SMTP ERROR: QUIT command failed: 5Ul2̔4Oi6 
2016-10-17 07:42:16 Connection: closed'`

以下是我的PHPMailer for config的内容。这适用于本地microapache,但一旦它进入我们的IIS,没有骰子:

$mail->isSMTP();                                   

$mail->Host = 'smtp.example.org.uk';  // Specify main and backup SMTP servers

$mail->SMTPAuth = false;                               // Enable SMTP authentication

$mail->Port = 25;                                    // TCP port to connect to

$mail->setFrom('noreply@example.org', "example");

$mail->addAddress('b.jones@example.org', 'B JONES');     // Add a recipient

$mail->Subject = 'Referral from: '.$_POST["staffName"]. '.';

$mail->AddEmbeddedImage('img/banner.jpg', 'banner');

$mail->AddEmbeddedImage('img/logo.jpg', 'logo');
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->IsHTML(true);

PHP的其余部分只是向正文添加内容。 (我已经在一些行中添加了示例,省略了smtp主机和东西。)

1 个答案:

答案 0 :(得分:0)

首先,您使用的是旧版本的PHPMailer,因此update it

你的剧本没有错 - 这是一个环境问题。请注意,一旦尝试使用TLS,它就会失败。您是否已从早期版本切换到PHP 5.6+?这通常会导致此问题,因为PHP 5.6及更高版本默认启用证书验证。另一个常见原因是未启用OpenSSL扩展。两者都包含在the PHPMailer troubleshooting guide中。

相关问题