8

我已经成功地在少数人内部使用的桌面上使用 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 桌面主机名

页面上没有显示任何错误,apache 日志中也没有显示任何错误,如果它们没有显示,我通常会在其中得到 PHP 错误。

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

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

请帮忙。谢谢。

4

5 回答 5

13

劫持帖子说我有同样的问题,但在默认情况下设置 TLS 的示例中,将端口设置为 465 而没有将 SMTPSecure 设置为“ssl”

于 2015-06-14T23:14:23.550 回答
2

可悲的是,这可能永远不会帮助遇到同样问题的其他人,但我只需将端口更改为 465 就可以让一切正常工作。

于 2013-04-01T17:51:38.157 回答
1

最终为我的配置找到了解决方案。
只需将 ssl:// 添加到 smtp.google.com
$mail->Host = 'ssl://smtp.gmail.com';

于 2019-07-31T16:55:43.407 回答
1

我遇到过同样的问题。在发送方法之后没有任何显示。我意识到加密是错误的,我确实使用了 SMTPS

$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
// Enable TLS encryption, `PHPMailer::ENCRYPTION_SMTPS` also accepted
于 2019-09-27T14:57:34.180 回答
1

如果你有一个托管在 Hostgator 中的服务器(共享主机),这就是为我解决的问题:(
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
即使PHPMailer中的官方示例建议使用ENCRYPTION_STARTTLS

于 2020-08-16T01:56:37.763 回答