开发者社区> 问答> 正文

ECS 解决windows系统下php.ini邮件配置正确不发送邮件的问题

php.ini邮件配置正确但不发送邮件。报错如下

Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first 

展开
收起
开发者说 2019-07-15 09:24:10 790 0
1 条回答
写回答
取消 提交回答
  • 问题原因

    php mail()函数不可用,需要安装sendmail 。

     

    解决方案

    1.从http://glob.com.au/sendmail/下载sendmail.zip 

    2.解压到C:下,例如:【C:\php\sendmail】最好短路径,长路径名有可能产生问题。 

    3.修改【php.ini】如下 

    sendmail_path = "C:\wamp\sendmail\sendmail.exe -t" 

    4.根据自己的配置环境修改【sendmail.ini】。 

    第一次最好启用debug.log_file,error_logfile,以查看sendmail是否生效。 

    5.重启apache 

    用sendmail结合其它的smtp服务器,如smtp.163.com来实现发邮件。现在大部分邮箱都要求smtp验证,所以要在sendmail.ini中加入用户名和密码。 

    php.ini配置 (以用163邮箱为例) 

    [mail function] 
    ; For Win32 only. SMTP = smtp.163.com 
    smtp_port = 25 
    ; For Win32 …… 

    用sendmail结合其它的smtp服务器,如smtp.163.com来实现发邮件。现在大部分邮箱都要求smtp验证,所以要在sendmail.ini中加入用户名和密码。 

    php.ini配置 (以用163邮箱为例) 

    [mail function] 
    ; For Win32 only. SMTP = smtp.163.com 
    smtp_port = 25 
    ; For Win32 only. sendmail_from = 4u4v@163.com 
    ; For Unix only. You may supply arguments as well (default: “sendmail -t -i”). sendmail_path = “D:\xampp\sendmail\sendmail.exe -t” 
    

    主要配置三项,【smtp】、【smtp_port】和【sendmail_path】 

    【sendmail.ini】配置 

    [sendmail] 
    ; you must change mail.mydomain.com to your smtp server smtp_server=smtp.163.com 
    smtp_port=25 
    auth_username=yourusername 
    auth_password=yourpassword 
    force_sender=yourusername@163.com 

    以上都是已163为例子的,请更具自己的实际需要修改自己的邮箱配置

    2019-07-22 11:29:01
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
如何运维千台以上游戏云服务器 立即下载
网站/服务器取证 实践与挑战 立即下载
ECS计算与存储分离架构实践 立即下载