phpmailer發(fā)送gmail郵件實(shí)例詳解
更新時(shí)間:2013年06月24日 10:56:58 作者:
本篇文章是對(duì)phpmailer發(fā)送gmail郵件實(shí)例進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
復(fù)制代碼 代碼如下:
<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>
您可能感興趣的文章:
- PHPMailer使用教程(PHPMailer發(fā)送郵件實(shí)例分析)
- 有關(guān)phpmailer的詳細(xì)介紹及使用方法
- PHPMailer安裝方法及簡(jiǎn)單實(shí)例
- PHPMailer郵件發(fā)送的實(shí)現(xiàn)代碼
- 163的郵件用phpmailer發(fā)送(實(shí)例詳解)
- PHPMailer發(fā)送HTML內(nèi)容、帶附件的郵件實(shí)例
- PHP使用PHPMailer發(fā)送郵件的簡(jiǎn)單使用方法
- PHPMailer 中文使用說(shuō)明小結(jié)
- Linux服務(wù)器下PHPMailer發(fā)送郵件失敗的問(wèn)題解決
相關(guān)文章
用PHP偽造referer突破網(wǎng)盤(pán)禁止外連的代碼
一般的國(guó)內(nèi)網(wǎng)盤(pán)為控制流量,都會(huì)禁止網(wǎng)盤(pán)內(nèi)的文件外鏈。點(diǎn)網(wǎng)盤(pán)里文件的鏈接一般都會(huì)轉(zhuǎn)到專(zhuān)門(mén)的下載頁(yè)面,必須從這個(gè)頁(yè)面才能下載文件。2008-06-06
php中使用ExcelFileParser處理excel獲得數(shù)據(jù)(可作批量導(dǎo)入到數(shù)據(jù)庫(kù)使用)
使用ExcelFileParser處理excel獲得數(shù)據(jù) 可以用作批量導(dǎo)入到數(shù)據(jù)庫(kù)使用,需要獲取excel數(shù)據(jù)的朋友可以參考下。2010-08-08
php class中self,parent,this的區(qū)別以及實(shí)例介紹
我容易混淆public,private,protected,還容易混淆this,self這些東西。前面已經(jīng)寫(xiě)了一篇關(guān)于public,private,protected 博文了,下面來(lái)說(shuō)一下this,self,parent的用法2013-04-04
php常用Output和ptions/Info函數(shù)集介紹
本篇文章是對(duì)php中常用Output和ptions/Info函數(shù)集進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06
php注冊(cè)系統(tǒng)和使用Xajax即時(shí)驗(yàn)證用戶名是否被占用
這篇文章主要為大家詳細(xì)介紹了php注冊(cè)系統(tǒng)和使用Xajax即時(shí)驗(yàn)證用戶名是否被占用,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-08-08
php程序的國(guó)際化實(shí)現(xiàn)方法(利用gettext)
這里我們主要介紹window平臺(tái)下使用php的擴(kuò)展gettext實(shí)現(xiàn)程序的國(guó)際化。2011-08-08
php計(jì)算給定時(shí)間之前的函數(shù)用法實(shí)例
這篇文章主要介紹了php計(jì)算給定時(shí)間之前的函數(shù)用法,實(shí)例分析了php計(jì)算時(shí)間的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-04-04

