【问题标题】:PHPMailer - HangsPHPMailer - 挂起
【发布时间】:2016-06-27 00:05:02
【问题描述】:

我正在尝试通过 PHPMailer 发送电子邮件。我已将 PHPMailer 文件解压缩到服务器并拥有此代码。我有额外的“要求”,正如其他帖子中关于发送时挂起的建议。

它正在读取代码,就好像我错过了“正文”一样,我收到一条错误消息。

我尝试了以下不同代码的多个示例,但都挂起。我已经添加和更改,现在放弃了!我有一个简单的按钮调用此代码和浏览器(尝试多次)只是挂起。任何想法我做错了什么?

require 'PHPMailer/PHPMailerAutoload.php';
require 'PHPMailer/class.smtp.php';

$mail = new PHPMailer;

$mail->isSMTP();                // Set mailer to use SMTP

$mail->Host = 'smtp.eastlink.ca';  // Specify main and backup SMTP servers

$mail->Username = 'ns@eastlink.ca';                 // SMTP username

$mail->Password = '*******';                           // SMTP password

$mail->From = 'ns@eastlink.ca';

$mail->FromName = 'bob';

$mail->addAddress('dsmith@eastlink.ca', 'D');     // Add a recipient

$mail->addReplyTo('ns@eastlink.ca', 'Information');

$mail->isHTML(true);          // Set email format to HTML

$mail->Subject = 'Here is the subject';

$mail->Body    = 'This is the HTML message body <b>in bold!</b>';

$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {

    echo 'Message could not be sent.';

    echo 'Mailer Error: ' . $mail->ErrorInfo;

} else {

    echo 'Message has been sent';

}

【问题讨论】:

  • 你不需要那个额外的要求。不要在所有事情上都依赖 SO - 周围有很多不好的建议。转到straight to the source,使用示例,阅读文档。

标签: php html email phpmailer freeze


【解决方案1】:

您似乎没有指定端口

尝试添加:

$mail->SMTPAuth = true;
$mail->Port = 25;

见:http://my.eastlink.ca/customersupport/internet/faqs/email.aspx

根据EastLink Doc,与无线设备连接时(非共享):

服务器类型:SMTP 端口:465 或 587 服务器名称:smtp.eastlink.ca 使用 STARTTLS

那就试试吧:

$mail->SMTPAuth = true;
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
// OR 
$mail->SMTPSecure = 'tls';

【讨论】:

  • 你不必:PHPMailer 默认使用端口 25。
  • 代码仍然丢失:$mail->SMTPAuth = true;
  • 感谢您的帮助!我已按照建议添加了这些行,并收到消息:缺少扩展名:openssl 邮件程序错误:缺少扩展名:openssl 看起来我必须编辑 php.ini 文件。再次感谢
猜你喜欢
  • 2013-03-19
  • 1970-01-01
  • 2018-08-30
  • 1970-01-01
  • 2014-02-06
  • 2015-06-20
  • 2018-07-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多