简体   繁体   English

PHPMailer - 挂起

[英]PHPMailer - Hangs

I am trying to send an email via PHPMailer.我正在尝试通过 PHPMailer 发送电子邮件。 I have unzipped the PHPMailer file to the server and have this code.我已将 PHPMailer 文件解压缩到服务器并拥有此代码。 I have the extra 'require' as it has been suggested in other posts regarding hanging when sending.我有额外的“要求”,因为它已在其他帖子中建议发送时挂起。

It is reading the code as if I miss out the 'body' I get an error message saying so.它正在阅读代码,就好像我错过了“主体”一样,我收到一条错误消息。

I have tried multiple examples of different code as below and all hang.我已经尝试了多个不同代码的示例,如下所示,都挂了。 I have added and altered and now given up!我已经添加和修改,现在放弃了! I have a simple button that calls this code and the browser (tried multiple) just hangs.我有一个调用此代码的简单按钮,浏览器(尝试了多个)只是挂起。 Any ideas what I am doing wrong?任何想法我做错了什么?

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';

}

You don't seem to specifying a port您似乎没有指定端口

Try adding:尝试添加:

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

See: http://my.eastlink.ca/customersupport/internet/faqs/email.aspx请参阅: http : //my.eastlink.ca/customersupport/internet/faqs/email.aspx

According to EastLink Doc, when connected with wireless device (not shared):根据 EastLink Doc,当与无线设备(未共享)连接时:

Server Type: SMTP Port: 465 or 587 Server Name: smtp.eastlink.ca Use STARTTLS服务器类型:SMTP 端口:465 或 587 服务器名称:smtp.eastlink.ca 使用 STARTTLS

So Try:所以尝试:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM