解析php中用PHPMailer來發(fā)送郵件的示例(126.com的例子)
更新時間:2013年06月24日 11:08:14 作者:
本篇文章是對php中用PHPMailer來發(fā)送郵件的示例(126.com的例子)進行了詳細的分析介紹,需要的朋友參考下
<?php
require_once('../class.phpmailer.php');
$mail= new PHPMailer();
$body= "我終于發(fā)送郵件成功了!呵呵!goodboy xxxxxxx!<br/><a>http://news.qq.com/a/20111115/000792.htm?qq=0&ADUIN=594873950&ADSESSION=1321316731&ADTAG=CLIENT.QQ.3493_.0</a>";
//采用SMTP發(fā)送郵件
$mail->IsSMTP();
//郵件服務(wù)器
$mail->Host = "smtp.126.com";
$mail->SMTPDebug = 0;
//使用SMPT驗證
$mail->SMTPAuth = true;
//SMTP驗證的用戶名稱
$mail->Username = "xxxxxxx@126.com";
//SMTP驗證的秘密
$mail->Password = "password";
//設(shè)置編碼格式
$mail->CharSet = "utf-8";
//設(shè)置主題
$mail->Subject = "測試";
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
//設(shè)置發(fā)送者
$mail->SetFrom('xxxxxxx@126.com', 'test');
//采用html格式發(fā)送郵件
$mail->MsgHTML($body);
//接受者郵件名稱
$mail->AddAddress("xxxxxxx@126.com", "test");//發(fā)送郵件
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
require_once('../class.phpmailer.php');
$mail= new PHPMailer();
$body= "我終于發(fā)送郵件成功了!呵呵!goodboy xxxxxxx!<br/><a>http://news.qq.com/a/20111115/000792.htm?qq=0&ADUIN=594873950&ADSESSION=1321316731&ADTAG=CLIENT.QQ.3493_.0</a>";
//采用SMTP發(fā)送郵件
$mail->IsSMTP();
//郵件服務(wù)器
$mail->Host = "smtp.126.com";
$mail->SMTPDebug = 0;
//使用SMPT驗證
$mail->SMTPAuth = true;
//SMTP驗證的用戶名稱
$mail->Username = "xxxxxxx@126.com";
//SMTP驗證的秘密
$mail->Password = "password";
//設(shè)置編碼格式
$mail->CharSet = "utf-8";
//設(shè)置主題
$mail->Subject = "測試";
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
//設(shè)置發(fā)送者
$mail->SetFrom('xxxxxxx@126.com', 'test');
//采用html格式發(fā)送郵件
$mail->MsgHTML($body);
//接受者郵件名稱
$mail->AddAddress("xxxxxxx@126.com", "test");//發(fā)送郵件
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
您可能感興趣的文章:
- phplist及phpmailer(組合使用)通過gmail發(fā)送郵件的配置方法
- PHP借助phpmailer發(fā)送郵件
- thinkphp使用phpmailer發(fā)送郵件的方法
- phpmailer發(fā)送郵件之后,返回收件人是否閱讀了郵件的方法
- phpmailer在服務(wù)器上不能正常發(fā)送郵件的解決辦法
- php多種形式發(fā)送郵件(mail qmail郵件系統(tǒng) phpmailer類)
- PHP使用PHPMailer發(fā)送郵件的簡單使用方法
- PHPMailer使用教程(PHPMailer發(fā)送郵件實例分析)
- 使用 PHPMAILER 發(fā)送郵件實例應(yīng)用
- PHPMailer郵件類利用smtp.163.com發(fā)送郵件方法
- phpmailer簡單發(fā)送郵件的方法(附phpmailer源碼下載)
相關(guān)文章
php中html_entity_decode實現(xiàn)HTML實體轉(zhuǎn)義
這篇文章主要介紹了php中html_entity_decode實現(xiàn)HTML實體轉(zhuǎn)義的相關(guān)資料,需要的朋友可以參考下2018-06-06深入解讀php中關(guān)于抽象(abstract)類和抽象方法的問題分析
這篇文章主要介紹了php中關(guān)于抽象(abstract)類和抽象方法的問題分析,有需要的朋友可以參考一下2014-01-01php中關(guān)于token驗證的相關(guān)問題詳解
這篇文章主要介紹了php中關(guān)于token驗證的相關(guān)問題詳解的相關(guān)資料,需要的朋友可以參考下2023-05-05