我的环境:XAMPP v3.2.1 准备工作 1.检查有没有sendmail程序,在xampp安装目录下的sendmail文件夹下。没有则下载sendmail.zip(http://glob.com.au/sendmail/),然后解压并放在在xampp目录下。 2.去mail.google.com注册一个google的邮箱,比如账号:user@gmai
我的环境:XAMPP v3.2.1
准备工作
1.检查有没有sendmail程序,在xampp安装目录下的sendmail文件夹下。没有则下载sendmail.zip(http://glob.com.au/sendmail/),然后解压并放在在xampp目录下。
2.去mail.google.com注册一个google的邮箱,比如账号:user@gmail.com,密码:passwd
配置步骤:
1.php.ini中如下设置:
; SMTP = localhost;
smtp_port = 25;
sendmail_from = sendmail_path = "C:/xampp/sendmail/sendmail.exe -t"
也就是注释掉"SMTP"、"smtp_port"、"sendmail_from",设置sendmail_path变量的值为以上所示(根据自己电脑上sendmail.exe的目录自行设置)。
2.sendmail.ini中如下设置
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=TLS
error_logfile=error.log
debug_logfile=debug.log
auth_username=user@gail.com
auth_password=passwd
测试代码:
<?php $now = date("Y-m-d h:i:s"); $headers = 'From: name<sender@qq.com>'; $body = "hi, this is a test mail.\nMy email: sender@qq.com"; $subject = "test mail"; $to = "recver@qq.com"; if (mail($to, $subject, $body, $headers)) { echo 'success!'; } else { echo 'fail'; } ?>以上代码执行后recver@qq.com 会收到发过来的邮件,但是邮件头中的sender@qq.com会被替换成user@gmail.com。

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

SublimeText3 Linux新版
SublimeText3 Linux最新版

WebStorm Mac版
好用的JavaScript开发工具

禅工作室 13.0.1
功能强大的PHP集成开发环境

Atom编辑器mac版下载
最流行的的开源编辑器