Parse the example of 126.com that USES PHPMailer to send mail

  • 2020-06-19 09:54:18
  • OfStack

< ?php
require_once('../class.phpmailer.php');
$mail= new PHPMailer();
$body= "I finally managed to send the email! Ha ha! goodboy xxxxxxx! < br/ > < a > http://news.qq.com/a/20111115/000792.htm?qq=0 & ADUIN=594873950 & ADSESSION=1321316731 & ADTAG=CLIENT.QQ.3493_.0 < /a > ";
// Use SMTP to send emails
$mail- > IsSMTP();
// Mail server
$mail- > Host = "smtp.126.com";
$mail- > SMTPDebug = 0;
// Verify using SMPT
$mail- > SMTPAuth = true;
//SMTP authenticated user name
$mail- > Username = "xxxxxxx@126.com";
//SMTP verified secrets
$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 sender
$mail- > SetFrom('xxxxxxx@126.com', 'test');
// Send emails in html format
$mail- > MsgHTML($body);
// Recipient email name
$mail- > AddAddress (" xxxxxxx@126.com ", "test"); // Send emails
if(!$mail- > Send()) {
echo "Mailer Error: " . $mail- > ErrorInfo;
} else {
echo "Message sent!";
}

Related articles: