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

≡放荡痞女 提交于 2019-12-10 18:01:15

问题


I need some help. I am trying to send an email from a php script. My environment comprises of the following:

Operating System: Windows 8

XAMPP version: 1.8.2

php version: 5.4.19

I have the following php script:

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

The following configuration on send mail configuration file:

smtp_server=smtp.gmail.com

; smtp port (normally 25)

smtp_port=465

auth_username=sugar.donkey+gmail.com
auth_password=[MYPASSWORDHERE]

The configurations on 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

I dont get error when I run the php script, but I also dont seem to receive an email. Where am I going wrong ?


回答1:


I am not sure what os you are running on your webserver, however;

Most Linux installations have sendmail preinstalled, there is always a hassle of setting up SPF/PTR records, to ensure that the email sent by your PHP script is not flagged as spam. A SMTP client called MSMTP can be used to send emails using third-party SMTP servers, this can also be used by PHP's mail() in the place of sendmail.

I hope this helps

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

Also for localhost testing, check this out. http://blogs.bigfish.tv/adam/2009/12/03/setup-a-testing-mail-server-using-php-on-mac-os-x/




回答2:


Even I am trying to get this configuration work :)

in your case i believe you need to comment out in php.ini

the configuration should be

; 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

Thank you



来源:https://stackoverflow.com/questions/20396449/php-ini-sendmail-configuration-to-send-an-email-using-a-php-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!