1·、下载phpmailer
2、修改class.phpmailer.php
增加变量
$FromEmail = ‘’;
修改下面内容:
$result .= $this->AddrAppend('From', $from);
成如下内容:
if($this->FromName != '') {
$fromname ='<'.$this->FromName.'>';
} else {
$fromname = '';
}
$result .= $this->HeaderLine('From', $this->FromEmail.$fromname);
$result .= $this->HeaderLine('Reply-TO', $this->FromEmail.$fromname);
3、创建一个sendEmail.php
<?php
require('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP(); //tell the class to use smtp
$mail->Host = 'smtp.163.com;smtp.qq.com';
$mail->SMTPAuth = true;
$mail->Username = 'weizhenzhenceshi@163.com';
$mail->Password = '***';
$mail->From = 'weizhenzhenceshi@163.com';
$mail->FromName = 'Mailer';
$mail->FromEmail = '2415972681@qq.com';
$mail->AddAddress('1433692080@qq.com', '邓珍珍');
$mail->Subject = 'First phpmailer message';
$mail->Body = 'HI,\N\N This is my first e-mail sent through phpmailer';
$mail->WordWrap = 50;
if(!$mail->Send()) {
echo 'Mailer error: '.$mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
密码是你使用的邮箱账号的密码。
发送邮箱,是已授权的邮箱,即,上面的邮箱账号。