php 使用sendmail发送邮件

1.下载sendmail
  下载地址:https://www.glob.com.au/sendmail/sendmail.zip
  下载后解压到你的php环境目录下,我用的phpstudy,解压到了D:\phpStudy\PHPTutorial

 

 

2.修改php配置文件,打开php.ini,搜索mail function,我用的163邮箱,修改配置如下:

 

3.修改sendmai的配置文件:

smtp_server=smtp.163.com //smtp服务器
auth_username=ceshi@163.com //发件邮箱
auth_password=ceshi//发件邮箱密码
force_sender=ceshi@163.com //发件邮箱
#上面的auth_username和auth_password一定要可以登录的邮箱和密码,不然发送失败。

4.php测试代码如下:

$data = mail("6666666@qq.com", "测试", "测试邮件");

if ($data) {
echo 'success!';
} else {
echo 'fail';
}

 

posted @ 2020-09-14 18:24  流浪2024  阅读(849)  评论(0)    收藏  举报