2911/081
Phpmailer鐨勭敤娉
鍏充簬phpmailer鐨勪笅杞借鍘http://phpmailer.codeworxtech.com/
鏈绠鍗曠殑璇达紝phpmailer灏辨槸鐢ㄦ潵鍙戦侀偖浠剁殑涓涓猵hp绫汇
璋冪敤鐨勮瘽鍏跺疄涓嬭浇鐨勫寘閲屾湁example鏂囦欢鍖咃紝閲岃竟鏄畬鏁寸殑渚嬪瓙銆
鎭╋紝涓嬭竟鏄竴涓猻mtp锛
< ?php
require("class.phpmailer.php");
//鍐欎釜鑷畾涔夊嚱鏁
function smtp_mail ( $sendto_email, $subject, $body, $extra_hdrs, $user_name) {
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "smtp.163.com"; // SMTP servers 浠163閭涓轰緥
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "163鐨勯偖绠辩敤鎴峰悕"; // SMTP username 娉ㄦ剰锛氭櫘閫氶偖浠惰璇佷笉闇瑕佸姞 @鍩熷悕
$mail->Password = "163閭瀵嗙爜"; // SMTP password
$mail->From = "youremail"; // 鍙戜欢浜洪偖绠
$mail->FromName = "Street13绠$悊鍛"; // 鍙戜欢浜
$mail->CharSet = "utf8"; // 杩欓噷鎸囧畾瀛楃闆嗭紒鎸囧畾涓篏B2312浼氫贡鐮侊紒
$mail->Encoding = "base64";
$mail->AddAddress($sendto_email,"username"); // 鏀朵欢浜洪偖绠卞拰濮撳悕
$mail->AddReplyTo("youremail","youremail");
$mail->IsHTML(true); // send as HTML
// 閭欢涓婚
$mail->Subject = $subject;
// 閭欢鍐呭
$mail->Body = '
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta></head>
<body>
娆㈣繋鏉ュ埌yourdomain
</body>
</html>
';
$mail->AltBody ="text/html";
if(!$mail->Send())
{
echo "閭欢鍙戦佹湁璇
";
echo "閭欢閿欒淇℃伅: " . $mail->ErrorInfo;
exit;
}
else {
echo "$user_name 閭欢鍙戦佹垚鍔!";
}
}
// 鍙傛暟璇存槑(鍙戦佸埌, 閭欢涓婚, 閭欢鍐呭, 闄勫姞淇℃伅, 鐢ㄦ埛鍚)
smtp_mail('youremail', '娆㈣繋鏉ュ埌yourdomain锛', 'NULL', 'yourdomain', 'username');
?>
gmail璺焢op3鐨勭敤娉曞熀鏈浉鍚岋紝瀵圭収鐫鏀瑰氨鍙互浜嗐