无法使用phpMailer SMTP发送电子邮件
PHP脚本无法使用phpMailer SMTP发送电子邮件,php,email,xampp,smtp,phpmailer,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
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
据我所知,连接已建立,但由于某些原因,电子邮件未发送
在问这个可敬的社区之前我采取的步骤
您正在连接的邮件服务器有问题。如果我
telnet mail1.warmacher.com 25
,它会连接,但不会响应。这似乎不是一个应对措施,它只是坏了。您设置的短超时不允许SMTP允许的最大等待时间(5分钟),尽管它似乎没有任何帮助。您的代码很好-您需要修复邮件服务器
服务器应该很好。我使用此帐户登录到webmail并发送/接收电子邮件。我使用的是ISP配置3,我没有进入mailserver的web gui访问权限。Webmail不需要SMTP-它可以通过IMAP读取并使用sendmail发送。无论如何,邮件服务器在您尝试发送的端口上没有响应。如果它不能通过telnet工作,那么它也不能通过PHPMailer工作;这是服务器的问题,不是客户端的问题。这就是我的想法。所以还有两个谜团。1.服务器上怎么可能已经有了发送电子邮件的功能邮件发送脚本2.什么样的配置是错误的。。。我应该在post服务器上更改什么样的设置?3.服务器是否有可能只对域上的smtp请求做出响应?它可能是通过不同的路由发送的,例如,如果您有一个本地邮件服务器在localhost上充当中继,那么通过PHP mail()函数发送就可以了。否则,您应该检查您连接到的服务器上的邮件日志-如果您有访问权限的话。