title: Send email from localhost running XAMMP in PHP using GMAIL mail server
body: <p>I try to send an email from localhost to my yahoo email account using php mail() function, the return says I successfully send the email but I did not get any email. I've been reading and trying many so called 'simple way' to send email but the result are disappointing, none of them work for me. Below are the code, the configurations and the error message. Can someone enlighten me with this? Thanks.</p>
  
  <p>php code</p>
  
  <pre><code>&lt;?php
  $to      = 'myemail@yahoo.com';
  $subject = 'Fake sendmail test';
  $message = 'If we can read this, it means that our fake Sendmail setup works!';
  $headers = 'From: myemail@egmail.com' . "\r\n" .
             'Reply-To: myemail@gmail.com' . "\r\n" .
             'X-Mailer: PHP/' . phpversion();
  
  if(mail($to, $subject, $message, $headers)) {
      echo 'Email sent successfully!';
  } else {
      die('Failure: Email was not sent!');
  }
  ?&gt;
  </code></pre>
  
  <p>Configuration for php.ini (I'm using gmail mail server)</p>
  
  <blockquote>
    <p>SMTP =smtp.gmail.com<br>
    smtp_port =587<br>
    sendmail_from = myemail@gmail.com<br>
    sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"</p>
  </blockquote>
  
  <p>Configuration for sendmail.ini</p>
  
  <blockquote>
    <p>smtp_server=smtp.gmail.com<br>
    smtp_port=587<br>
    smtp_ssl=tls<br>
    error_logfile=error.log<br>
    debug_logfile=debug.log<br>
    auth_username=myemail@gmail.com<br>
    auth_password=mypassword<br>
    force_sender=myemail@gmail.com</p>
  </blockquote>
  
  <p>error message in sendmail error log with port 587</p>
  
  <blockquote>
    <p>13/10/02 13:36:41 : Must issue a STARTTLS command first. k4sm129639pbd.11 - gsmtp</p>
  </blockquote>