我已经在内部少数人使用的桌面上使用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();
?>
我从调试中获得的唯一内容是
客户 - &gt; SMTP:EHLO thedesktophostname
页面上没有显示错误,而且如果不显示,我通常会收到PHP错误的apache日志中没有任何错误。
我可以通过端口25从桌面远程登录到主机,甚至可以输入EHLO命令并从服务器获得良好的响应。
我以前不记得有这个问题,虽然我可能已经解决了一次。我在这里或谷歌上找不到任何有用的东西。
请帮忙。感谢。
答案 0 :(得分:10)
劫持帖子说我有同样的问题,但是在没有将SMTPSecure设置为'ssl'的情况下将端口设置为465,默认设置为TLS
答案 1 :(得分:2)
遗憾的是,这可能不会帮助其他有同样问题的人,但我只需将端口更改为465即可完成所有工作。
答案 2 :(得分:1)
如果您在Hostgator中托管服务器(共享托管),这就是为我解决的问题:
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
(即使PHPMailer中的官方示例建议使用ENCRYPTION_STARTTLS
)
答案 3 :(得分:0)
最终找到我的配置解决方案。
只需将ssl://添加到smtp.google.com
$mail->Host = 'ssl://smtp.gmail.com';
答案 4 :(得分:0)
我有同样的问题。 send方法后无显示。 我意识到加密是错误的,我确实使用了SMTPS
Azure