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.找到邮箱的设置
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,感谢关注
标签:qq,sendmail,smtp,mail,PHP,com,port,邮件 来源: https://blog.csdn.net/qq_40933487/article/details/113188500