PHPMailer 发送邮件
<?php
include ('class.phpmailer.php');
$config = array(
? ? ? ?'host'=>'smtp.163.com',
? ? ? ?'port'=>'25',
? ? ? ?'user'=>'haocaiges@163.com',
? ? ? ?'passwd'=>'******',
? ? ? ?'from'=>'haocaiges@163.com',
? ? ? ?'fromname'=>'廣東',
? ? ? ?);
$subject = 'this is a test mail';
$body = '<table style="background:#dfdfdf"><tr><td>測試內容</td></tr><tr><td>這是內容</td></tr></table>';
$address='1207204940@qq.com';
$username='本人';
$mail = new PHPMailer();
$mail->CharSet = 'gb2312';
$mail->IsSMTP();
$mail->Host = $config['host'];
$mail->Port = $config['port'];
$mail->From = $config['from'];
$mail->FromName = $config['fromname'];
$mail->SMTPAuth = true;
$mail->Username = $config['user'];
$mail->Password = $config['passwd'];
$mail->Subject=$subject;
$mail->AltBody="text/html";
$mail->MsgHTML($body);
$mail->AddAddress($address,$username);
if(!$mail->Send())
{
? ?echo "Mail Error :".$mail->ErrorInfo;
}else
{
? ?echo "恭喜發(fā)送成功!";
}
轉載于:https://blog.51cto.com/haocaige/1398370
總結
以上是生活随笔為你收集整理的PHPMailer 发送邮件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Ubuntu安装JDK配置环境变量
- 下一篇: Windows Server 2012