Home  >  Article  >  Backend Development  >  Parsing an example of using PHPMailer to send emails in PHP (example of 126.com)_PHP Tutorial

Parsing an example of using PHPMailer to send emails in PHP (example of 126.com)_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:03:48970browse

require_once('../class.phpmailer.php');
$mail= new PHPMailer();
$body= "I finally sent the email successfully! Haha! goodboy xxxxxxx "
//Send mail using SMTP
$mail->IsSMTP();
//Mail server
$mail->Host = "smtp.126.com";
$ mail->SMTPDebug = 0;
//Use SMPT authentication
$mail->SMTPAuth = true;
//Username for SMTP authentication
$mail->Username = "xxxxxxx @126.com";
//The secret of SMTP authentication
$mail->Password = "password";
//Set the encoding format
$mail->CharSet = "utf- 8";
//Set the theme
$mail->Subject = "Test";
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer! ";
//Set the sender
$mail->SetFrom('xxxxxxx@126.com', 'test');
//Send email in html format
$mail-> ;MsgHTML($body);
//Recipient email name
$mail->AddAddress("xxxxxxx@126.com", "test");//Send email
if(!$ mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327808.htmlTechArticle?php require_once('../class.phpmailer.php'); $mail= new PHPMailer(); $body= "I finally sent the email successfully! Haha! goodboy xxxxxxx! br/ahttp://news.qq.com/a/20111115/000792.htm...
Statement:
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