邮件包下载地址:
https://github.com/PHPMailer/PHPMailer
代码:
// 引入PHPMailer的核心文件
include "PHPMailer-master/src/PHPMailer.php";
include "PHPMailer-master/src/SMTP.php";
header("content-type:text/html;charset=utf8");
$mail = new PHPMailer();
$mail->IsSMTP(); //设置要发送邮件
$mail->IsHTML(TRUE); //是否允许要发送html代码
$mail->CharSet = ‘UTF-8‘; //设置文字格式
$mail->SMTPAuth = TRUE; //是否需要身份验证
$mail->From = "邮箱账号@163.com";
$mail->FromName = "邮件名";
$mail->Host = "smtp.163.com"; //发送邮件的服务协议地址
$mail->Username = "用户名"; //用户名
$mail->Password = "授权码"; //授权码
$mail->Port = 25; //发邮件端口号默认25
$mail->AddAddress("收件人邮箱地址"); //收件人
$mail->Subject = "……"; //标题
$mail->Body = "……"; //内容
if ($mail->send()){
echo "发送成功";
}else{
echo "发送失败";
}
原文地址:https://www.cnblogs.com/wanglongfei/p/9905314.html