简体   繁体   English

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

[英]Unable to send email with phpMailer SMTP

PHP Script 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();
                                     }

Problem description 问题描述

Client has a script on his server which apparently runs. 客户在他的服务器上有一个显然可以运行的脚本。 I am trying to connect to his server which is possible but when I try to send email following error appears 我正在尝试连接到可能的他的服务器,但是当我尝试发送电子邮件时出现以下错误

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 

Far as I can understand that connection is estabilished but for some reason email is not send. 据我了解,已建立连接,但由于某种原因未发送电子邮件。

Steps I took prior to asking this honorable community 在问这个荣誉社区之前我采取的步骤

  1. Check if security is needed - None 检查是否需要安全性-无
  2. Check if port is correct - 25 is correct 检查端口是否正确-25正确
  3. Check if name/pwd correct - Yes. 检查名称/密码是否正确-是。 I can log into webmail on server 我可以在服务器上登录Webmail

There is something wrong with the mail server you're connecting to. 您要连接的邮件服务器出了点问题。 If I telnet mail1.warmacher.com 25 , it connects, but does not respond. 如果我通过telnet mail1.warmacher.com 25连接,但没有响应。 It doesn't appear to be a greet delay countermeasure, it's just broken. 它似乎不是一个欢迎的延迟对策,只是被打破了。 The short timeout you've set doesn't allow the maximum wait (5 minutes) that SMTP permits, though it doesn't appear to help anyway. 您设置的短暂超时不允许SMTP允许的最大等待时间(5分钟),尽管它似乎也无济于事。 Your code is fine - you need to get the mail server fixed. 您的代码很好-您需要修复邮件服务器。

  1. Problem caused by unknown postfix server settings.( Basically it is not a problem but a feature ) 由未知的postfix服务器设置引起的问题。(基本上这不是问题,而是功能)
  2. Curret setting does not allow access to postfix from outside of server Curret设置不允许从服务器外部访问后缀

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

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