PHPMailer 是一个强大的 PHP 编写的邮件发送类,使用它可以更加便捷的发送邮件,并且还能发送附件和 HTML 格式的邮件,同时还能使用 SMTP 服务器来发送邮件。
大家也许会问,PHP 不是已经内置了 mail() 函数了吗,为什么要用 PHPMailer 呢?mail() 函数功能并不完善,只能发送文本的 e-mail,并且 mail() 函数只能应用在 Linux 服务器(很多装在 Win 主机的 WP 博客用户注册收不到邮件也是这个原因),还有一个最大的问题就是使用 mail() 函数发送的邮件没有进行身份验证,很多邮件收不到使用 mail() 函数发送的邮件或者发送的邮件直接进入垃圾邮箱。
PHPMailer 主要功能
在邮件中包含多个 TO、CC、BCC 和 REPLY-TO。
平台应用广泛,支持的 SMTP 服务器包括 Sendmail、qmail、Postfix、Gmail、Imail、Exchange 等等。
支持嵌入图像,附件,HTML 邮件。
可靠的强大的调试功能。
支持 SMTP 认证。
自定义邮件头。
支持 8bit、base64、binary 和 quoted-printable 编码。
PHPMailer 的简单使用
这里使用最常用的 Gmail 来做介绍。

require_once("class.smtp.php");
$mail = new PHPMailer();
$mail->CharSet ="UTF-8"; //设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置为 UTF-8
$mail->IsSMTP(); // 设定使用SMTP服务
$mail->SMTPAuth = true; // 启用 SMTP 验证功能
$mail->SMTPSecure = "ssl"; // SMTP 安全协议
$mail->Host = "smtp.gmail.com"; // SMTP 服务器
$mail->Port = 465; // SMTP服务器的端口号
$mail->Username = "your_name@gmail.com"; // SMTP服务器用户名
$mail->Password = "your_password"; // SMTP服务器密码
$mail->SetFrom(‘发件人地址’, ‘发件人名称’); // 设置发件人地址和名称
$mail->AddReplyTo("邮件回复人地址","邮件回复人名称");
// 设置邮件回复人地址和名称
$mail->Subject = ”; // 设置邮件标题
$mail->AltBody = "为了查看该邮件,请切换到支持 HTML 的邮件客户端";
// 可选项,向下兼容考虑
$mail->MsgHTML(”); // 设置邮件内容
$mail->AddAddress(‘收件人地址’, "收件人名称");
//$mail->AddAttachment("images/phpmailer.gif"); // 附件
if(!$mail->Send()) {
echo "发送失败:" . $mail->ErrorInfo;
} else {
echo "恭喜,邮件发送成功!";
}
下载:PHPMailer,如果是 WordPress 用户,则无需下载,WordPress 已经自带 PHPMailer。
波比源码 » 使用PHPMailer发送邮件的设置方法
levaquin cost order levaquin 500mg for sale
avodart online cheap flomax 0.4mg order zofran online
brand aldactone purchase aldactone online buy diflucan without prescription
cheap ampicillin brand bactrim 960mg purchase erythromycin
fildena us fildena 100mg brand purchase methocarbamol
sildenafil without prescription sildenafil 50mg price order estradiol 1mg
lamictal 50mg oral mebendazole without prescription order retin without prescription
order tadalafil 10mg generic buy tadalafil 20mg generic diclofenac 100mg cost
indomethacin 50mg us trimox over the counter trimox 500mg ca
arimidex buy online order clarithromycin 250mg buy sildenafil pill
deltasone 5mg sale cialis 100mg india order sildenafil 50mg
original cialis rezeptfrei sicher kaufen viagra kaufen ohne rezept viagra 50mg kaufen
buy generic provigil 100mg 10mg cialis acetazolamide 250mg price
buy altace 10mg online cheap order astelin 10ml generic purchase azelastine
order generic clonidine 0.1mg spiriva 9mcg usa oral spiriva 9mcg
buy buspar 5mg pill buy oxybutynin pill buy oxybutynin online cheap
terazosin 5mg cheap pioglitazone price azulfidine 500mg sale
olmesartan 10mg cost verapamil oral acetazolamide usa
prograf 1mg brand trandate 100mg cost purchase ursodiol online
brand zyban 150 mg oral atomoxetine buy quetiapine 100mg generic
buy sertraline 100mg for sale kamagra 100mg price sildenafil 100mg sale
revia drug order revia generic buy aripiprazole 20mg generic
order dapsone 100mg generic purchase adalat pills perindopril usa
medroxyprogesterone over the counter cyproheptadine 4mg for sale periactin order
piracetam 800 mg ca viagra buy online viagra next day delivery usa
oral lasix doxycycline 100mg oral order plaquenil 400mg for sale
buy metformin online cheap atorvastatin canada cialis online
linezolid 600mg for sale linezolid 600mg without prescription play slots online
prilosec generic buy prilosec 10mg generic real money casino
help with term papers no deposit bonus codes play poker online free
clomiphene online order order albuterol 2mg online blackjack poker online
xenical 120mg cost diltiazem order zovirax without prescription
generic tadalafil 20mg inderal 10mg drug buy clopidogrel pills
cost allopurinol cheap crestor 20mg ezetimibe 10mg over the counter
domperidone 10mg canada order cyclobenzaprine pill cyclobenzaprine generic
order losartan online cozaar 25mg cheap topiramate 100mg canada
baclofen 10mg over the counter purchase ozobax pills toradol 10mg cheap
buy sumatriptan 25mg generic sumatriptan cheap avodart 0.5mg generic
generic colchicine 0.5mg planning poker online online slot games
order ranitidine 150mg sale buy generic celecoxib 200mg celecoxib 200mg for sale
online slots real money free spins no deposit usa that roulette
flomax 0.2mg price order ondansetron 8mg sale purchase aldactone without prescription
cialis 20mg pills buy acillin online cheap cipro 1000mg usa
buy metronidazole 400mg sale buy bactrim 960mg for sale bactrim cost
keflex price order erythromycin 250mg online cheap order erythromycin 250mg without prescription
sildenafil 50mg generic viagra next day order cialis 10mg without prescription
casino arizona play online roulette for fun oral tadalafil
essay writing stromectol pills stromectol pills canada
sildenafil over the counter order lamotrigine 200mg pill lamictal online order
real money poker online where can i buy ed pills tadalafil order online
brand furosemide 40mg order hydroxychloroquine sale order plaquenil pills
buy fildena for sale fildena 50mg canada oral rhinocort
buy deltasone sale buy deltasone 5mg generic order vermox online cheap
buy generic retin buy avanafil generic brand avana 100mg
buy tadalafil 20mg without prescription order tadalafil 20mg without prescription order indomethacin online
terbinafine 250mg ca suprax 200mg canada buy trimox 250mg online
buy naprosyn 250mg buy cefdinir 300mg online cheap prevacid canada
order clarithromycin pill order meclizine 25mg pill order antivert 25mg online cheap
singulair 5mg pills cheap sildenafil pill viagra 25mg price
cialis 10mg price generic tadalafil 10mg tadalafil for sale online
buy ivermectin 3mg for humans dapsone uk dapsone pills
doxycycline 200mg us cleocin 300mg tablet cleocin 150mg price
cheap asacol irbesartan 300mg oral buy irbesartan 150mg generic
temovate online order amiodarone 100mg pill cordarone pill
buy acetazolamide without prescription purchase imdur generic order imuran generic
buy digoxin 250 mg online cheap digoxin 250 mg price molnupiravir 200 mg pills
cost carvedilol 25mg oxybutynin 2.5mg canada order amitriptyline 50mg generic
buy generic alendronate order generic nitrofurantoin 100mg order ibuprofen 400mg for sale
Thank you great posting about essential oil. Hello Administ . Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…
order indocin 75mg indocin drug buy cenforce pill
order pamelor 25mg sale paxil usa purchase paroxetine without prescription
order famotidine 20mg for sale buy pepcid 40mg online remeron buy online
ropinirole pills order requip online cheap order labetalol 100 mg pill
I really love to read such an excellent article. Helpful article. Hello Administ . Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…
fenofibrate 160mg oral purchase viagra without prescription viagra online order
buy minocycline 100mg pill neurontin 800mg canada terazosin 1mg oral
order generic tadalafil 20mg best ed pills online best ed pills non prescription
order provigil 100mg sale stromectol 12mg brand buy promethazine 25mg generic
deltasone 20mg canada prednisone 10mg sale amoxil 1000mg ca
buy fildena for sale lyrica 75mg generic buy propecia pills
ondansetron 8mg pill sulfamethoxazole cheap bactrim uk
albuterol cheap ventolin 2mg pill buy augmentin 1000mg generic