0

I'm using windows 7 and xampp 1.8(mercury mail is on) and trying to send email from localhost using gmail id. but its not working. heres my email.php :

<?php
$to="receiver.email@gmail.com";
$subject='the subject';
$message="dfdgh";
$headers='From:my.email@gmail.com'."\r\n".'Host:ssl://smtp.gmail.com'."\r\n".'Port:465'."\r\n".'Username:my.email@gmail.com'."\r\n".'Password:mypassword'."\r\n".'Reply-To:my.email@gmail.com'."\r\n".'X-Mailer:PHP/'.phpversion();
mail($to, $subject, $message, $headers);
?>

and heres my localhost php smtp configuration that I changed

;SMTP = localhost
;smtp_port = 25
SMTP =ssl://smtp.gmail.com
smtp_port = 465
; For Win32 only.
;http://php.net/sendmail-from
;sendmail_from = postmaster@localhost
ssl://smtp.gmail.com
sendmail_from = my.email@gmail.com

I got no error message after I execute the code but didn't receive any email.

What wrong did I do ?

-Thanks.

user1844626
  • 1,838
  • 7
  • 24
  • 37

2 Answers2

0

Gmail SMTP has stopped working on 465 and SSL so use below configuration.

Before it was worked perfectly but now its working on below config.

SMTP =tls://smtp.gmail.com
smtp_port = 587
tls://smtp.gmail.com

Use 587 SMTP_PORT and use TLS.

and if its not working then replace SMTP = tls line to SMTP = aspmx.l.google.com

Dipesh Parmar
  • 27,090
  • 8
  • 61
  • 90
0

debug it first in

mail($to, $subject, $message, $headers);

try to write down a condition to see if mail is sending

if(mail($to, $subject, $message, $headers)){
echo 'Success';
}
else{
echo 'Failed';
}
Jhonathan H.
  • 2,734
  • 1
  • 19
  • 28