0

I am testing to send mail form localhost using gmail smtp,

I have made following setting

C:\wamp\sendmail\sendmail.ini

smtp_server=smtp.gmail.com
;smtp port (normally 25)
smtp_port=465
smtp_ssl=ssl
default_domain=localhost
error_logfile=error.log
;debug_logfile=debug.log
auth_username = at*******t@gmail.com
auth_password = my*********password

php.ini

.
extension=php_smtp.dll
.
.
[mail function]
; For Win32 only.
; http://php.net/smtp
; SMTP = smtp.gmail.com
; http://php.net/smtp-port
; smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
; sendmail_from = at*******t@gmail.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t").
; http://php.net/sendmail-path
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t -i"

index.php

<?php
$to = "towhomemailid@gmail.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: at*******t@gmail.com@gmail.com" . "\r\n" .
"CC: anothermailid@gmail.com";

$a = mail($to,$subject,$txt,$headers);
var_dump($a); 
?>

Output

 false

I have enabled the IMAP setting in gmail account as well, Also enabled the php_smtp, php_openssl, php_sockets under PHP extensions

When I tried I am getting a security mail in gmail that there is one suspicious login and I have added this device to known one as well, it seems the script is hitting the gmail account but return is getting false.

What possible change I am missing?

EDIT:

I tried with an enterprise email id ..

enterpriseemailid@example.com

it was working but not with my perswonal id, even the two step verification is off, so error seems to be somewhere in google setting, can anyone suggest possible solution

1 Answers1

0

Well this is a pretty common problem. Here are some solutions which might help you.

1). Use tls instead of ssl.

2). If you've enabled 2-Factor Authentication, make sure you make appropriate settings in your gmail account to accept the login.

Akshay
  • 2,244
  • 3
  • 15
  • 34
  • I tried it with 587/25 its showing still false and with 465 its loading infinite. and 2 Step verification is off in my gmail account. –  Aug 14 '15 at 07:37