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,感谢关注

 

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...