PHPMailer - 挂起 [英] PHPMailer - Hangs
问题描述
正在读取代码,好像我错过了身体我得到一个错误消息说这样。
我已经尝试过不同代码的多个示例,如下所有挂起。我已经添加和改变了,现在放弃了!我有一个简单的按钮,调用这个代码和浏览器(尝试多个)只是挂起。任何想法我做错了什么?
require'PHPMailer / PHPMailerAutoload.php';
需要PHPMailer / class.smtp.php;
$ mail = new PHPMailer;
$ mail-> isSMTP(); //设置邮件程序使用SMTP
$ mail-> Host ='smtp.eastlink.ca'; //指定主服务器和备份SMTP服务器
$ mail->用户名='ns@eastlink.ca'; // SMTP username
$ mail-> Password ='*******'; // SMTP密码
$ mail-> From ='ns@eastlink.ca';
$ mail-> FromName ='bob';
$ mail-> addAddress(tosmith@eastlink.ca','D'); //添加收件人
$ mail-> addReplyTo('ns@eastlink.ca','信息');
$ mail-> isHTML(true); //将电子邮件格式设置为HTML
$ mail-> Subject ='这里是主题';
$ mail-> Body ='这是黑体中的HTML消息正文< b>< / b>';
$ mail-> AltBody ='这是非HTML邮件客户端的纯文本的主体;
如果(!$ mail-> send()){
echo'无法发送消息。
echo'Mailer Error:'。 $ MAIL-> ERRORINFO;
} else {
echo'已发送消息';
}
不要指定一个端口
尝试添加:
$ mail-> SMTPAuth = true;
$ mail-> Port = 25;
请参阅: http://my.eastlink.ca/customersupport/internet/faqs/email.aspx
根据EastLink文档,当与无线设备(未共享)连接时:
服务器类型:SMTP
端口:465或587
服务器名称: smtp.eastlink.ca
使用STARTTLS
所以尝试:
$ mail-> SMTPAuth = true;
$ mail-> Port = 465;
$ mail-> SMTPSecure ='ssl';
// OR
$ mail-> SMTPSecure ='tls';
I am trying to send an email via PHPMailer. I have unzipped the PHPMailer file to the server and have this code. 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
According to EastLink Doc, when connected with wireless device (not shared):
Server Type: SMTP Port: 465 or 587 Server Name: smtp.eastlink.ca Use STARTTLS
So Try:
$mail->SMTPAuth = true;
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
// OR
$mail->SMTPSecure = 'tls';
这篇关于PHPMailer - 挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!