PHPMailer Send Email_PHP Tutorial

WBOY
Release: 2016-07-13 17:39:50
Original
1100 people have browsed it

刚刚出炉的自己博客文章来与大家共享下^_^,下面文章转载自我的博客:久酷博客
上篇文章PHP mail()方法发送邮件部分邮箱无法收到邮件问题 提到要介绍一下phpmailer这款免费开源的php 邮件程序,下面我们来看看吧,以下资料全部来自phpmailer官方网站:

PHPMailer 也是一个功能强大的邮件类

PHPMailer的主要功能特点:

支持邮件 s/mime加密的数字签名
支持邮件多个 TOs, CCs, BCCs and REPLY-TOs
可以工作在任何服务器平台,所以不用担心WIN平台无法发送邮件的问题的
支持文本/HTML格式邮件
可以嵌入image图像
对于邮件客户端不支持HTML阅读的进行支持
功能强大的发送邮件调试功能debug
自定义邮件header
冗余SMTP服务器支持
支持8bit, base64, binary, and quoted-printable 编码
文字自动换行
支持多附件发送功能
支持SMTP服务器验证功能
在Sendmail , qmail , Postfix , Gmail , Imail, Exchange 等平台测试成功
提供的下载文件中,包括内容详细的说明文档及示例说明,所以不用担心难于上手的问题!
PHPMailer 非常小巧、简单、方便、快捷
以上资料由Jiucool 翻译自phpmailer 官网,转载请注明!

Usage of PHPMailer (here is using gmail smtp to send emails as an example. Of course, sendmail pop and other methods are also supported):
First go to http://phpmailer.worxware.com/ to download the latest version of the package
After the download is completed, find the two classes class.phpmailer.php and class.smtp.php and put them in your own directory!
Then create a new php file and name it here: phpmail_jiucool.php
phpmail_jiucool.php The content is as follows:
I directly write the email sending module as a function postmail_jiucool_com(). You can call this function directly when using it. , the function content is:
function postmail_jiucool_com($to,$subject = "",$body = ""){
//Author:Jiucool WebSite: http://www.jiucool.com
/ /$to represents the recipient address $subject represents the email title $body represents the email body
//error_reporting(E_ALL);
error_reporting(E_STRICT);
date_default_timezone_set("Asia/Shanghai");// Set time zone Dongba District
require_once(class.phpmailer.php);
include("class.smtp.php");
$mail = new PHPMailer(); //new a PHPMailer object comes out
$body = eregi_replace("[]",,$body); //Perform necessary filtering on the email content
$mail->CharSet = "UTF-8";//Set the email encoding, The default is ISO-8859-1. If you send Chinese, this must be set, otherwise it will be garbled.
$mail->IsSMTP(); // Set to use SMTP service.
$mail->SMTPDebug = 1; Enable SMTP debugging
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // Enable SMTP authentication function
$mail->SMTPSecure = "ssl";                                                                                 // SMTP server port number
$mail->Username = "SMTP server username"; // SMTP server username
$mail->Password = "SMTP server password"; // SMTP server password
$mail- >SetFrom(Sender address, such as admin#jiucool.com #Replace with @, sender name);
$mail->AddReplyTo("Email reply address, such as admin#jiucool.com #Replace with @","Name of the person who responded to the email");
$mail->Subject = $subject;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer! - From www.jiucool.com"; // optional, comment out and test
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($ address, "recipient name");
//$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! Congratulations, the email was sent successfully!"; 
                                                                                            

http://www.bkjia.com/PHPjc/486258.html

www.bkjia.com

http: //www.bkjia.com/PHPjc/486258.htmlTechArticleI just released my blog article to share with you ^_^, the following article is reproduced from my blog: Jiuku Previous blog article: PHP mail() method sends emails and some mailboxes cannot receive emails...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template