PHPMailer挂在发送 [英] PHPMailer Hangs on Send

查看:63
本文介绍了PHPMailer挂在发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在内部供少数人使用的桌面上使用WAMPSERVER成功地设置了一个Web应用程序,该程序使用PHPMailer到内部SMTP服务器,而无需进行加密或身份验证,并且可以正常工作.

该桌面崩溃了,我已经迁移到新"桌面.我有一个SVN设置,所以我什至都在使用大多数相同的文件和配置.一个可能重要的区别是,旧台式机为64位,而新台式机为32位.这意味着我正在使用不同版本的WAMPSERVER.

邮件挂起了.我没有收到PHP错误或PHP超时.我只是从未到达脚本的结尾.疯狂的部分是它可以与身份验证,ssl和gmail一起使用.只是无法满足我所需要的简单案例.

这有效:

<?php
require('class.phpmailer.php');
$mail=new PHPMailer();
$mail->ISSMTP();
$mail->Host='smtp.gmail.com';
$mail->Subject='test subj';
$mail->Body='the body email test';
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
$mail->Username   = "myemail@gmail.com";  // GMAIL username
$mail->Password   = "mypassword";            // GMAIL password
$mail->AddAddress('toemail@supersecret.com', 'John Doe');
$mail->SetFrom('something@gmail.com', 'First Last');
$mail->Send();
?>

这曾经但现在没有:

<?php
require('class.phpmailer.php');
$mail=new PHPMailer();
$mail->ISSMTP();
$mail->Host='smtp.internal.com';
$mail->Subject='test subj';
$mail->Body='the body email test';
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
$mail->Port       = 25;                   // set the SMTP port for the GMAIL server
$mail->AddAddress('myaddress@somewhere.com', 'John Doe');
$mail->SetFrom('someaddress@mightbereal.com', 'First Last');
$mail->Send();
?>

我从调试中得到的唯一东西是

客户端-> SMTP:EHLO thedesktophostname

该页面上没有错误显示,并且在apache日志中也没有任何内容,如果没有显示,我通常会在其中得到PHP错误.

我可以从桌面上的端口25远程登录到主机,甚至可以键入EHLO命令,并从服务器获得良好的响应.

我以前不记得有这个问题,尽管可能我已经解决了一次.在这里或Google上找不到任何有用的东西.

请帮助.谢谢.

解决方案

不幸的是,这可能永远不会对遇到相同问题的其他人有所帮助,但是我只需将端口更改为465就可以使所有工作正常. /p>

I had successfully setup a web app using WAMPSERVER on a desktop used by a few people internally, this used PHPMailer to an internal SMTP server without encryption or authentication and it worked.

That desktop crashed and I've migrated to a "new" desktop. I had an SVN setup so I was even using most of the same files and config. One difference which might matter is that the old desktop was 64-bit and the new is 32-bit. This means I'm using different versions of WAMPSERVER.

The mailer just hangs. I don't get a PHP error or a PHP timeout. I just never reach the end of my script. The crazy part about this is that it works with authentication, ssl, and gmail. It just won't work with the extra simple case I need.

This works:

<?php
require('class.phpmailer.php');
$mail=new PHPMailer();
$mail->ISSMTP();
$mail->Host='smtp.gmail.com';
$mail->Subject='test subj';
$mail->Body='the body email test';
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
$mail->Username   = "myemail@gmail.com";  // GMAIL username
$mail->Password   = "mypassword";            // GMAIL password
$mail->AddAddress('toemail@supersecret.com', 'John Doe');
$mail->SetFrom('something@gmail.com', 'First Last');
$mail->Send();
?>

this used to, but now does not:

<?php
require('class.phpmailer.php');
$mail=new PHPMailer();
$mail->ISSMTP();
$mail->Host='smtp.internal.com';
$mail->Subject='test subj';
$mail->Body='the body email test';
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
$mail->Port       = 25;                   // set the SMTP port for the GMAIL server
$mail->AddAddress('myaddress@somewhere.com', 'John Doe');
$mail->SetFrom('someaddress@mightbereal.com', 'First Last');
$mail->Send();
?>

The only thing I get from debug is

CLIENT -> SMTP: EHLO thedesktophostname

No errors display on the page and nothing in the apache log, where I normally get PHP errors, if they don't display.

I can telnet to the host from the desktop on port 25 and even type in the EHLO command and get a good response from the server.

I don't remember having this issue before, although it's possibly I've already solved it once. I couldn't find anything that helped here or on The Google.

Please help. Thanks.

解决方案

sadly this probably won't ever help anyone else who has this same problem, but I was able to get everything working by just changing the port to 465.

这篇关于PHPMailer挂在发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆