您好我正在尝试使用PHPMailer,它不能正常工作,但是错误
连接:打开ssl://smtp.gmail.com:465,超时= 300,options = array()
这是我的代码
require_once('mailFiles/PHPMailerAutoload.php');
echo (extension_loaded('openssl')?'SSL loaded':'SSL not loaded')."<br/>";
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPDebug = 4;
$mail->Debugoutput = 'html';
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
// $mail->SMTPSecure = 'tls';
$mail->Host = 'smtp.gmail.com';
// $mail->Host = gethostbyname('smtp.gmail.com');
// $mail->Host = 'tls://smtp.gmail.com:587';
// $mail->Port = 587;
$mail->Port = 465;
$mail->Username = "xs4arabiabahrain@gmail.com";
$mail->Password = "mailpass";
$mail->setFrom('mail@gmail.com', 'Firstz Last');
$mail->addAddress('myemail@gmail.com', 'MAAGE-EMAIL User');
$mail->IsHTML(true);
//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML('Hi test 123');
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');
$result = $mail->send();
if (!$result) {
echo ("Mailer Error: ");
echo ($mail->ErrorInfo);
} else {
echo ("Message sent!");
}
累了 tls 仍然无法正常工作。