php 使用 PHPMAILER 发送邮件实例
使用 PHPMAILER 发送邮件实例 [代码片段(45行)]
<?php include (\'class/class.phpmailer.php\'); $config = array( \'host\'=>\'smtp.163.com\', \'port\'=>\'25\', \'user\'=>\'***\', \'passwd\'=>\'****\', \'from\'=>\'xxxx@163.com\', \'fromname\'=>\'北京\', ); $subject = \'this is a test mail\'; $body = \'<table style=\"background:#dfdfdf\"><tr><td>测试内容</td></tr><tr><td>这是内容</td></tr></table>\'; $address=\'111111111@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 \"恭喜发送成功!\"; } //该片段来自于http://outofmemory.cn
- 上一篇:php 输入参数过滤类
- 下一篇:PHP正确解析UTF-8字符串
精彩图集
精彩文章