PHPMailer不支持PHP5.3,适用于PHP5.6

时间:2016-07-23 05:43:20

标签: php ssl phpmailer

PHPMailer有这个奇怪的问题。完全相同的代码适用于安装了PHP5.6的本地主机,但是当我使用Cpanel托管它时它会失败。我确认通过echo (extension_loaded('openssl')?'SSL loaded':'SSL not loaded')."\n";启用了SSL。

$m = new PHPMailer;
$m->isSMTP();
$m->SMTPAuth = true;
/*  $m->SMTPDebug =4; */
$m->Host = 'smtp.gmail.com';
$m->Username = '*********@gmail.com';
$m->Password= '*********';
$m->SMTPSecure = 'ssl';
$m->Port = 465;
$m->isHTML();
$m->Subject = 'Contact Form';
$m->Body='Sender: ' . $fields['name'] . ' ('.$fields['email'].') <p>' . $fields['message']. '</p>';
$m->FromName ='From Website';
$m->CharSet = 'UTF-8';
$m->AddAddress('**********@gmail.com','********');

if($m->send()){

echo "<script language='javascript'> alert('Message Sent Succesfully. We'll get back to you soon.'); window.location = '$url';</script>";

    die();
}
else{

$errors='Sorry, something went wrong. Please try again later.  ' . $m->ErrorInfo;

} 

$m->ErrorInfo带来的错误是:

  

SMTP connect()失败。 https://github.com/phpmailer/phpmailer/wiki/troubleshooting

我尝试取消注释$m->SMTPDebug =4;行,但所有内容都是

之类的内容
  

无法连接SMTP服务器

感谢任何帮助,提前谢谢!

0 个答案:

没有答案