This question has been asked repeatedly but none seem to have a solution:
I'm running this test php file:
<?php
$to = "email@gmail.com";
$subject = "Test";
$message = "This is a test";
$from = "From: email@gmail.com";
if(mail($to, $subject, $message, $from)) {
echo 'Email sent successfully!';
} else {
die('Failure');
}
?>
after changing the following lines in php.ini
:
[mail function]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"
as well as these lines in sendmail.ini
:
smtp_server=smtp.gmail.com
smtp_port=587 ;I've tried 465 but gmail doesn't seem to like to connect to SSL
auth_username=email@gmail.com
auth_password=password
Mail fails to send and the debug log is as follows:
15-02-21 13:35:59 ** --- MESSAGE BEGIN ---
15-02-21 13:35:59 ** To: email@gmail.com
15-02-21 13:35:59 ** Subject: Test
15-02-21 13:35:59 ** From: email@gmail.com
15-02-21 13:35:59 **
15-02-21 13:35:59 ** This is a test
15-02-21 13:35:59 ** --- MESSAGE END ---
15-02-21 13:36:01 ** Connecting to smtp.gmail.com:587
15-02-21 13:36:02 ** Connected.
15-02-21 13:36:02 << 220 mx.google.com ESMTP z10sm6176887pas.18 - gsmtp<EOL>
15-02-21 13:36:02 >> EHLO Lenovo-PC<EOL>
15-02-21 13:36:02 << 250-mx.google.com at your service, []<EOL>250-SIZE 35882577<EOL>250-8BITMIME<EOL>250-STARTTLS<EOL>250-ENHANCEDSTATUSCODES<EOL>250-PIPELINING<EOL>250-CHUNKING<EOL>250 SMTPUTF8<EOL>
15-02-21 13:36:02 ** Authenticating as email@gmail.com
15-02-21 13:36:02 >> STARTTLS<EOL>
15-02-21 13:36:02 << 220 2.0.0 Ready to start TLS<EOL>
15-02-21 13:36:02 >> QUIT<EOL>
15-02-21 13:36:02 << bunch of special characters
15-02-21 13:36:02 ** Disconnected.
15-02-21 13:36:02 ** Disconnecting from smtp.gmail.com:587
15-02-21 13:36:02 ** Disconnected.
15-02-21 13:36:02 ** Disconnected.
15-02-21 13:36:02 ** Connection Closed Gracefully.
Any help is appreciated.