Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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('[email protected]','Helo','This is a test','From:[email protected]');
?>

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 ?

like image 955
kya Avatar asked Oct 19 '25 18:10

kya


1 Answers

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/

like image 142
Carlos Pliego Avatar answered Oct 22 '25 07:10

Carlos Pliego



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!