PHP Mailer错误:无法发送消息.Mailer错误:SMTP connect()失败

这是我的代码:

require 'phpmailertesting/PHPMailerAutoload.php';

$mail = new PHPMailer;

//$mail->SMTPDebug = 3;                               // Enable verbose debug output

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'send.one.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'myemailhidden';                 // SMTP username
$mail->Password = 'mypasswordhidden';                           // SMTP password
$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also     accepted
$mail->Port = 465;                                    // TCP port to connect to

$mail->From = 'myemailhidden';
$mail->FromName = 'My Name';
$mail->addAddress('example@example.com');               // Name is optional

$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');

//$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
$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';
}

我尝试将端口和安全连接的类型更改为“ TSL”和“ SSL”,什么也没有.我已经看过答案了,没有一个人能解决.有什么答案吗?谢谢

我启用了SMTP调试器,这就是它的“连接:打开ssl://send.one.com:465,t = 300,opt = array()2014-12-15 15:46:40 SMTP错误:无法连接到服务器:连接超时(110)2014-12-15 15:46:40 SMTP connect()失败”

解决方法:

您的托管公司one.com故意阻止传出邮件端口,以限制恶意PHP脚本. send.one.com地址适用于外部邮件客户端,例如您的手机,电子邮件客户端等,不适用于来自您网站的内部邮件脚本.

根据他们关于从您的网站发送电子邮件的support document,您必须将主机更改为其内部SMTP地址mailout.one.com-由于这是内部中继,因此您还必须使用端口25并禁用任何安全性,例如TLS或SSL .您还必须禁用身份验证.

这是正确的配置:

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'mailout.one.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = false; // Authentication must be disabled
$mail->Username = 'myemailhidden';
$mail->Password = ''; // Leave this blank
$mail->Port = 25;                                    // TCP port to connect to
上一篇:java中将Excel中的数据导入SQLite数据库


下一篇:PHPMailer SMTP本地主机,证书错误