title: PHP: Sending mail from localhost with gmail smtp in wamp is accessing the account but not sending the mail?
body: <p>I am testing to send mail form localhost using gmail smtp,</p>
  
  <p>I have made following setting </p>
  
  <p><strong>C:\wamp\sendmail\sendmail.ini</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>php.ini</strong></p>
  
  <pre><code>.
  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"
  </code></pre>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;?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); 
  ?&gt;
  </code></pre>
  
  <p><strong>Output</strong> </p>
  
  <pre><code> false
  </code></pre>
  
  <p>I have enabled the IMAP setting in gmail account as well,
  Also enabled the <code>php_smtp, php_openssl, php_sockets</code> under  PHP extensions</p>
  
  <p>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.</p>
  
  <p>What possible change I am missing?</p>
  
  <p>EDIT: </p>
  
  <p>I tried with an enterprise email id .. </p>
  
  <pre><code>enterpriseemailid@example.com
  </code></pre>
  
  <p>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 </p>