阿里雲默認不容許訪問SMTP 25端口,可申請解封25端口或換ssl加密方式鏈接和端口html
$mail = new PHPMailer();阿里雲
$mail->IsSMTP();加密
# $mail->Host = 'smtp.exmail.qq.com'; # 本地可直接使用htm
$mail->Host = 'ssl://smtp.exmail.qq.com'; # 阿里雲線上使用ssl加密方式utf-8
$mail->Port = 465; # ssl方式 用465端口ssl
$mail->SMTPAuth = true; // 打開SMTP認證it
$mail->Username = 'xxx@xxx.com';base64
$mail->Password = 'yyyyyyy';coding
$mail->From = 'xxx@xxx.com';qq
$mail->FromName = iconv('utf-8', 'GBK', "xxx"); // 發件人
$mail->CharSet = 'GB2312';
$mail->Encoding = "base64";
$mail->IsHTML(true); // 郵件主題
$mail->Subject = iconv('utf-8', 'GBK', $subject); // 郵件內容
$mail->Body = iconv('utf-8', 'GBK', $message);
$mail->AltBody = "text/html";
if ($mail->Send()) {
exit('success');
} else {
exit($mail->ErrorInfo);
}