使用phpmailer smtp函数时收到错误消息。我使用的是php5,下面是我使用的代码。
require_once("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->Host = 'mail.mydomain.com';
$mail->Port = 21;
$mail->Username = xxx;
$mail->Password = xxx;
$mail->SetFrom($email, $firstname . " " . $lastname);
$mail->AddAddress($contact);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->WordWrap = 50;
$mail->isHTML(true);
$mail->Send();
if(!$mail->Send())
{
echo "email_has_not_been_sent <br><br>";
echo "Mailer Error: " . $mail->ErrorInfo;
$IsSent = 0;
exit;
}
这是错误消息。
SMTP -> ERROR: EHLO not accepted from server: 500 EHLO not understood
SMTP -> ERROR: HELO not accepted from server: 500 HELO not understood
SMTP -> ERROR: AUTH not accepted from server: 500 AUTH not understood
SMTP -> ERROR: RSET failed: 500 RSET not understood
SMTP Error: Could not authenticate. SMTP -> ERROR: MAIL not accepted from server: 500 MAIL not understood
答案 0 :(得分:1)
您的代码看起来不错,但我认为您正在使用更常用于FTP的端口... 25 and 587 are more commonly used as SMTP ports
一些基本的telneting应该告诉你发生了什么:
telnet smtp.gmail.com 587
然后输入命令EHLO
,您将看到gmail SMTP服务器的欢迎消息。
现在在你的服务器上尝试一下,你会看到你得到的东西
然后对更常见的SMTP端口尝试相同的操作: 25 和 587 ,您应该看到差异。