Home > Backend Development > PHP Tutorial > Example of sending phpmailer to NetEase 126 mailbox

Example of sending phpmailer to NetEase 126 mailbox

WBOY
Release: 2016-07-25 08:58:19
Original
1846 people have browsed it
This article introduces an example of using phpmailer to send emails from NetEase 126.com. Friends in need can refer to it.

Example of using PHPMailer class to send emails:

<?php
/**
* phpmailer发送邮件实例
* 发送网易邮箱126.com
* edit bbs.it-home.org
*/
require_once('../class.phpmailer.php');

$mail= new PHPMailer();

$body= "发送邮件成功";

//采用SMTP发送邮件
$mail->IsSMTP();

//邮件服务器
$mail->Host       = "smtp.126.com";
$mail->SMTPDebug  = 0;

//使用SMPT验证
$mail->SMTPAuth   = true;

//SMTP验证的用户名称
$mail->Username   = "jbxue@126.com";

//SMTP验证的秘密
$mail->Password   = "password";

//设置编码格式
$mail->CharSet  = "utf-8";

//设置主题
$mail->Subject    = "测试";

//$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!";

//设置发送者
$mail->SetFrom('jbxue@126.com', 'test');

//采用html格式发送邮件
$mail->MsgHTML($body);

//接受者邮件名称
$mail->AddAddress("jbxue@126.com", "test");//发送邮件
if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}
?>
Copy after login

You need to introduce the phpmailer class file, download address: PHPMailer email sending class V5.1 download address.



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