PHPMailer EHLO不支持SMTP错误

时间:2013-10-13 09:25:41

标签: php smtp phpmailer

我有这个代码,我想用它来发送邮件给我的客户,参数CENSORED(***):

include 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->Host = "smtp.email.it";
$mail->Port = 25; // or 587 465
$mail->IsHTML(true);
$mail->SMTPSecure = 'tls';
$mail->Username = "***";
$mail->Password = "***";
$mail->SetFrom('***');
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress('***');
 if(!$mail->Send())
    {
    echo "Mailer Error: " . $mail->ErrorInfo;
    }
    else
    {
    echo "Message has been sent";
    }

它连接但出错:

2013-10-13 09:13:25 CLIENT -> SERVER: EHLO *SITE_CENSORED*
2013-10-13 09:13:25 SMTP ERROR: EHLO command failed: Method EHLO is not supported.
2013-10-13 09:13:25 SMTP NOTICE: EOF caught while checking if connected
SMTP connect() failed.
Mailer Error: SMTP connect() failed.

1 个答案:

答案 0 :(得分:4)

将您的端口更改为587应该有效:

$mail->Port = 587; // or 587 465

我试图telnet:

telnet smtp.email.it 25 //not working

telnet smtp.email.it 465 //not working

telnet smtp.email.it 587 //works