php.ini,sendmail配置使用php脚本发送电子邮件


php.ini, sendmail configuration to send an email using a php script

我需要一些帮助。我正在尝试从php脚本发送一封电子邮件。我的环境包括以下内容:

操作系统:Windows 8

XAMPP版本:1.8.2

php版本:5.4.19

我有以下php脚本:

<?php
mail('sugar.donkey@gmail.com','Helo','This is a test','From:salt@goodness.com');
?>

发送邮件配置文件上的以下配置:

smtp_server=smtp.gmail.com
; smtp port (normally 25)
smtp_port=465
auth_username=sugar.donkey+gmail.com
auth_password=[MYPASSWORDHERE]

php.ini上的配置:

[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
; SMTP = smtp.gmail.com
; smtp_port = 465
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost

当我运行php脚本时,我不会出错,但我似乎也没有收到电子邮件。我哪里错了?

但是,我不确定您在Web服务器上运行的是什么操作系统;

大多数Linux安装都预装了sendmail,设置SPF/PTR记录总是很麻烦,以确保PHP脚本发送的电子邮件不会被标记为垃圾邮件。一个名为MSMTP的SMTP客户端可以用于使用第三方SMTP服务器发送电子邮件,这也可以由PHP的mail()代替sendmail使用。

我希望这能帮助

https://www.digitalocean.com/community/articles/how-to-use-gmail-or-yahoo-with-php-mail-function

同样对于localhost测试,请查看此项。http://blogs.bigfish.tv/adam/2009/12/03/setup-a-testing-mail-server-using-php-on-mac-os-x/

即使我正在尝试进行此配置:)

在您的情况下,我认为您需要在php.ini 中进行注释

配置应该是

; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = smtp.gmail.com
smtp_port = 465
; For Win32 only.
http://php.net/sendmail-from
sendmail_from = postmaster@localhost

感谢