怎么使用phpmailer实现邮件的发送??,phpmailer邮件来源:http://www.ido321.com/1103.html
发送邮件是常用的功能,lz今天在项目中也碰到了,特此分享一下。
首先,去下载phpmailer
1、https://github.com/dwqs/phpmailer
2、http://download.csdn.net/detail/u011043843/8063583
下载之后,将文件解压到项目目录的对应位置,将class.phpmailer.php和class.smtp.php引入项目中,看代码:(解压的文件不要删除,否则不行)
issmtp(); // 使用smtp方式发送$mail->charset =utf-8;//设置编码,否则发送中文乱码$mail->host = smtp.qq.com; // 您的企业邮局域名$mail->smtpauth = true; // 启用smtp验证功能$mail->username = 461147874@qq.com; // 邮局用户名(请填写完整的email地址)$mail->password = **********; // 邮局密码$mail->from = 461147874@qq.com; //邮件发送者email地址$mail->fromname = dwqs;$mail->addaddress($address, dwqs);//收件人地址,可以替换成任何想要接收邮件的email信箱,格式是addaddress(收件人email,收件人姓名)//$mail->addreplyto(, );//$mail->addattachment(/var/tmp/file.tar.gz); // 添加附件//$mail->ishtml(true); // set email format to html //是否使用html格式$mail->subject = 验证邮件; //邮件标题$mail->body = hello,这是测试邮件; //邮件内容$mail->altbody = this is the body in plain text for non-html mail clients; //附加信息,可以省略if(!$mail->send()) { echo 'mailer error: ' . $mail->errorinfo; } else { echo message sent!恭喜,邮件发送成功!; }?>
测试结果:
下一篇:你的大学,有多少遗憾?
在本地使用phpmailer发送邮件需要怎配置?
php使用phpmailer发送邮件不成功
服务器没有smtp
http://www.bkjia.com/phpjc/899960.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/899960.htmltecharticle怎么使用phpmailer实现邮件的发送??,phpmailer邮件 来源:http://www.ido321.com/1103.html 发送邮件是常用的功能,lz今天在项目中也碰到了,特此...