微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PHP配置邮件服务 sendmail

1.首先配置PHP.ini文件,找到下面这些

[mail function]
; For Win32 only.
; http://PHP.net/smtp
SMTP = smtp.qq.com
; http://PHP.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://PHP.net/sendmail-from
sendmail_from = yourmail@qq.com
 
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://PHP.net/sendmail-path
sendmail_path ="E:\aserver\sendmail\sendmail.exe -t "
mail.add_x_header = On

SMTP= smtp.qq.com  这里也可以配置成网易的163邮箱也可以

smtp_port = 25   认即可

sendmail_from="yourmail@qq.com"  写上自己的邮箱地址

sendmail_path ="E:\aserver\sendmail\sendmail.exe -t"  写上自己的sendmail.exe 路径

mail.add_x_header = On   认即可

 

2.设置sendmail.ini文件

[sendmail]
smtp_server=smtp.qq.com
; smtp port (normally 25)
smtp_port=25
smtp_ssl=auto
error_logfile=error.log
debug_logfile=debug.log
auth_username=yourmail@qq.com
auth_password=授权码

注意auth_password不是QQ密码,而是授权码

 

3.找到邮箱的设置

image.png

 

4.测试邮件服务,使用mail()函数

$to = "330435168@qq.com";
$subject = "盼图网";
$message = "<h1>登录验证码</h1>";
$from = "1029091536@qq.com";
$headers = "From: $from";
if(mail($to,$subject,$message,$headers)){
    echo "发送成功";
}else{
    echo "发送失败";
}

 

 

文章来源于本人个人博客    http://www.fdqiudapan.com/?id=7,感谢关注

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐