无法使用phpMailer SMTP发送电子邮件

时间:2017-05-07 19:07:54

标签: php email xampp smtp phpmailer

PHP脚本

require '../PHPMailerAutoload.php';

//Create a new PHPMailer instance
//Passing true to the constructor enables the use of exceptions for error handling
$mail = new PHPMailer(true);
try {
 $mail->Port       = 25;    
 $mail->Timeout = 10;
 $mail->isSMTP();   
 $mail->SMTPDebug = 3;
 $mail->CharSet = 'UTF-8'; 
 $mail->Host       = 'mail1.ClientWeb.com';
 $mail->SMTPAuth   = true; 
 $mail->Username   = 'test_mail@ClientWeb.com'; 
 $mail->Password   = 'pwd';  

 $mail->setFrom('from@example.com', 'First Last');
 $mail->addReplyTo('replyto@example.com', 'First Last');
 $mail->addAddress('keprta.martin@gmail.com', 'Martin Keprta');
 $mail->Subject = 'test';

 $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
 $mail->AltBody = 'This is a plain-text message body';
 $mail->addAttachment('images/phpmailer_mini.png');
 $mail->send();
 echo "Message sent!";
  } catch (phpmailerException $e) {
    echo $e->errorMessage();
  } catch (Exception $e) {
    echo $e->getMessage();
                                     }

问题描述

客户端在他的服务器上有一个显然运行的脚本。我试图连接到他的服务器,这是可能的,但当我尝试发送电子邮件后出现错误

2017-05-07 18:31:57 Connection: opening to mail1.warmacher.com:25, timeout=10, options=array ( ) 
2017-05-07 18:31:57 Connection: opened 
2017-05-07 18:32:07 SERVER -> CLIENT: 
2017-05-07 18:32:07 CLIENT -> SERVER: EHLO localhost 
2017-05-07 18:32:17 SERVER -> CLIENT: 
2017-05-07 18:32:17 SMTP ERROR: EHLO command failed: 
2017-05-07 18:32:17 CLIENT -> SERVER: HELO localhost 

我可以理解连接已经建立,但出于某种原因,电子邮件不会发送。

我在问这个光荣的社区之前采取的步骤

  1. 检查是否需要安全性 - 无
  2. 检查端口是否正确 - 25是否正确
  3. 检查名称/密码是否正确 - 是。我可以登录webmail 服务器

1 个答案:

答案 0 :(得分:0)

  1. 由未知的后缀服务器设置引起的问题。(基本上它不是问题,而是功能)
  2. Curret设置不允许从服务器外部访问postfix
相关问题