您好,欢迎访问一九零五行业门户网

PHPMailer实现发送邮件的方法介绍(附代码)

本篇文章给大家带来的内容是关于phpmailer实现发送邮件的方法介绍(附代码),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
phpmailer请在github下载,或者直接百度,也不难,虽然phpmailer里面一大堆东西,但是我们只需要
phpmailer.class.php
phpmailerautoload.class.php
smtp.class.php
然后通过composer安装phpmailer,这是我测试时写的例子,直接是在原生的.php文件里面写的,其实里面还有一些参数是没有用的,但是我并没有去测试,欢迎各位朋友指点
php虽然提供了mail()函数,但是我不会也没有研究过,而phpmailer是一个不错的邮件发送工具,使用起来也是非常简单!
<?phpinclude("class.phpmailer.php");include("class.smtp.php");//实例化$mail = new phpmailer();//设置smtp参数$mail->issmtp();$mail->smtpauth = true;$mail->smtpkeepalive = true;//$mail->smtpsecure = "ssl";$mail->host = "smtp.163.com";$mail->port = 25;//填写你的邮箱账号和密码$mail->username = "18681613053@163.com";$mail->password = "*********";//设置发送方,最好不要伪造地址$mail->from = "18681613053@163.com";$mail->fromname = "阳台大爷";//标题,内容,和备用内容$mail->subject = "163email";$mail->body = "163email body";$mail->altbody = "163email!!!纯文本";//如果邮件不支持html格式,则替换成该纯文本模式邮件$mail->wordwrap = 50; // 设置邮件每行字符数//$mail->msghtml($body);//设置回复地址$mail->addreplyto("18681613053@163.com","yy");//添加附件,此处附件与脚本位于相同目录下,否则填写完整路径//$mail->addattachment("attachment.zip");//设置邮件接收方的邮箱和姓名$mail->addaddress("704203193@qq.com","firstname lastname");//使用html格式发送邮件$mail->ishtml(true);//通过send方法发送邮件,根据发送结果做相应处理if(!$mail->send()) {echo "发送失败: " . $mail->errorinfo;} else {echo "邮件已经成功发送";}?>
相关推荐:
使用 phpmailer 发送邮件,phpmailer发送邮件
phpmailer简单发送邮件的方法(附phpmailer源码下载),phpmailer源码下载
以上就是phpmailer实现发送邮件的方法介绍(附代码)的详细内容。
其它类似信息

推荐信息