I am a beginner in PHP, and I am trying to send mail from my localhost but it does not work. Been looking through some solutions but nothing seems to help. Someone please advise.
Here is my sendmail.ini file (saved in C:\xampp\sendmail\sendmail.exe)
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=my-id@gmail.com
auth_password=my-password
force_sender=my-id@gmail.com
Here is a fraction of my php.ini on the SMTP part:
[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-id.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
Here is my PHP file:
<?php
$to = "test@gmail.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
I always receive "Message delivery failed no matter what I try. Please help