阿里云ECS发送企业邮件

<?php
use PHPMailerPHPMailerPHPMailer;
require '../vendor/autoload.php';

$mail = new PHPMailer(true);

try {
//Server settings
$mail->CharSet = 'utf-8';
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'ssl://smtp.mxhichina.com'; //使用阿里云注意使用ssl协议
$mail->SMTPAuth = true;
$mail->Username = 'xxx';
$mail->Password = 'xxx';
$mail->SMTPSecure = 'tls';
$mail->Port = 465; //阿里云开启端口

//Recipients
$mail->setFrom('xxx', 'xxxxxx');
$mail->addAddress('xxx', 'Joe User');
$mail->addAddress('xxx', 'Joe User');
$mail->addReplyTo('xxx', 'Information');

$mail->isHTML(true);
$mail->Subject = '阿里企业邮箱发送自动发送邮件';
$mail->Body = '<b>报警了....</b>';
$mail->AltBody = '报警邮件';

$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
原文地址:https://www.cnblogs.com/shiwenhu/p/9183105.html