1.使用XAMPP和localhost我正在尝试从php脚本向gmil发送邮件 2.在对帖子和其他资源中看到的文件php.ini和sendmail.ini进行所有更改之后,我无法从以下php代码行接收邮件:
<?php
mail('satanower1@gmail.com','hello this is a test','From: satanower1@gmail.com');
echo 'mail has been sent successfully.';
?>
我收到了回复声明,但我的收件箱中没有发送电子邮件
改变我尝试sendmail.ini
文件:来自xampp defoult的smtp_server = smtp.gmail.com
smtp_port = 465(我试过其他端口也是25等..)
更改我尝试了php.ini文件: SMTP = smtp.gmail.com和smtp_port = 465
有任何帮助吗?
答案 0 :(得分:0)
您需要在GMAIL中启用SMTP访问,您还需要允许不安全的客户端:
https://www.google.com/settings/security/lesssecureapps https://support.google.com/mail/answer/75726
sendmail config
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=auto
error_logfile=error.log
debug_logfile=debug.log
auth_username==*****@gmail.com
auth_password=*********
force_sender=*****@gmail.com
php config
[mail function]
SMTP=smtp.gmail.com
smtp_port=465
sendmail_from = *****@gmail.com
sendmail_path = "\"c:\xampp\sendmail\sendmail.exe\" -t"