Home > Backend Development > PHP Tutorial > Use PHPMailer to send emails, phpmailer to send emails_PHP Tutorial

Use PHPMailer to send emails, phpmailer to send emails_PHP Tutorial

WBOY
Release: 2016-07-13 10:07:57
Original
912 people have browsed it

Use PHPMailer to send emails, phpmailer to send emails

Reprinted http://blog.csdn.net/liruxing1715/article/details/7914974

PHPMailer’s official website: http://phpmailer.worxware.com/

PHPMailer latest class library download address: [Click to download]

PHPMailer GitHub download address: https://github.com/Synchro/PHPMailer. This page also provides usage examples, but it is not comprehensive.

How to use, see the code list for details:

header('Content-Type:text/html;Charset=utf-8');
require './PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set email to use SMTP
$mail->Host = 'mail.wanzhao.com'; // Mail server address
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->CharSet = "UTF-8"; // Set email encoding
$mail->setLanguage('zh_cn'); // Set error Chinese Tip
$mail->Username = 'wanzhao@wanzhao.com'; // SMTP username, that is, personal email address
$mail->Password = 'www123456'; // SMTP password, that is Personal email password
$mail->SMTPSecure = 'tls'; // Set to enable encryption, note: the php_openssl module must be turned on
$mail->Priority = 3; // Set email priority 1: High, 3: Normal (default), 5: Low
$mail->From = 'liruxing@wanzhao.com'; // Sender's email address
$mail->FromName = 'Li Ruxing' ; // Sender name
$mail->addAddress('liruxing1715@163.com', 'Lee'); // Add recipient
$mail->addAddress('ellen@example. com'); // Add multiple recipients
$mail->addReplyTo('info@example.com', 'Information'); // Add replyers
$mail->addCC(' liruxing1715@sina.com'); // Add carbon copy persons
$mail->addCC('512848303@qq.com'); // Add multiple carbon copy persons
$mail->ConfirmReadingTo = 'liruxing@wanzhao.com'; // Add the sending receipt email address, that is, when the recipient opens the email, it will ask whether a receipt has occurred
$mail->addBCC('734133239@qq.com'); // Add a blind copy person, the Mail Header will not display the blind copy person information
$mail->WordWrap = 50; // Set automatic line wrapping to 50 characters
$mail->addAttachment('./1 .jpg'); // Add attachment
$mail->addAttachment('/tmp/image.jpg', 'one pic'); // Add multiple attachments
$mail->isHTML( true); // Set the email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body in bold !. Time:'.date('Y-m-d H:i:s');
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit ;
}

echo 'Message has been sent';

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/954467.htmlTechArticleUse PHPMailer to send emails, phpmailer sends emails. Reprint http://blog.csdn.net/liruxing1715/article/details /7914974 PHPMailer’s official website: http://phpmailer.worxware.com/ PHP...
Related labels:
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