3

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 ?

Community
  • 1
  • 1
kya
  • 1,798
  • 8
  • 35
  • 61

2 Answers2

3

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/

Carlos Pliego
  • 859
  • 1
  • 8
  • 19
  • Hi, Im using windows 8 for development and windows server 2008 R2 for production. – kya Mar 09 '14 at 18:29
0

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

Maks3w
  • 6,014
  • 6
  • 37
  • 42