繁体   English   中英

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

[英]Unable to send email with phpMailer SMTP

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

您要连接的邮件服务器出了点问题。 如果我通过telnet mail1.warmacher.com 25连接,但没有响应。 它似乎不是一个欢迎的延迟对策,只是被打破了。 您设置的短暂超时不允许SMTP允许的最大等待时间(5分钟),尽管它似乎也无济于事。 您的代码很好-您需要修复邮件服务器。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM