国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

phpmailer發送gmail郵件實例詳解

2024-05-04 23:11:23
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:


<html>
<head>
<title>PHPMailer - SMTP (Gmail) basic test</title>
</head>
<body>
<?php
//error_reporting(E_ALL);
error_reporting(E_STRICT);
date_default_timezone_set('America/Toronto');
require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail= new PHPMailer();
$body= file_get_contents('contents.html');
$body= eregi_replace("[/]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host= "mail.gmail.com"; // SMTP server
$mail->SMTPDebug = 2;// enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true;// enable SMTP authentication
$mail->SMTPSecure = "ssl";// sets the prefix to the servier
$mail->Host= "smtp.gmail.com";// sets GMAIL as the SMTP server
$mail->Port= 465;// set the SMTP port for the GMAIL server
$mail->Username = "***@gmail.com"; // GMAIL username
$mail->Password = "***";// GMAIL password
$mail->SetFrom('****@gmail.com', 'First Last');
$mail->AddReplyTo("***@gmail.com","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$address = "***@gmail.com";
$mail->AddAddress($address, "John Doe");
$mail->AddAttachment("images/phpmailer.gif");// attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
</body>
</html>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大竹县| 湄潭县| 南江县| 惠东县| 望城县| 汝南县| 江源县| 明光市| 大渡口区| 阿坝| 屏东市| 铜川市| 大丰市| 泽库县| 婺源县| 裕民县| 杭州市| 中超| 日照市| 石家庄市| 平顶山市| 平果县| 镇巴县| 峨边| 岳池县| 长岛县| 卢湾区| 炉霍县| 平阴县| 文化| 香格里拉县| 广元市| 海阳市| 班戈县| 达拉特旗| 邻水| 临颍县| 仁怀市| 宜城市| 朝阳市| 石林|