首页 > 代码库 > 在程序中集成发邮件功能

在程序中集成发邮件功能

<?php
require_once(“class.phpmailer.php”);

/*发送邮件*/
function sendMail($to, $subject, $message)
{
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = “smtp.qq.com”;
$mail->SMTPAuth = true;
$mail->Username = “10000@qq.com”;
$mail->Password = “***************”;
$mail->Port=25;
$mail->CharSet = “utf-8″;
$mail->From = “10000@qq.com”; //邮件发送者email地址
$mail->FromName = “邮件发送者名称”;
$mail->AddAddress(“$to”, “*****”);
$mail->Subject = $subject; //邮件标题
$mail->Body = $message; //邮件内容
$mail->AltBody = “This is the body in plain text for non-HTML mail clients”;
return $mail->Send();
}

sendMail(‘customer@163.com’, ‘测试邮件功能’, ‘测试邮件功能’);

?>

在程序中集成发邮件功能