I know this question has many answers on this website but there is no answer worked for me. So please help me in this ...
I'm trying to send a message in php mail function
And this is index.php
<?php
$to = "test@gmail.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: my gmail ID@gmail.com";
try{
if(mail($to, $subject, $txt, $headers))
echo "email has been sent successfully";
else
echo "Unknown Error";
}catch(Exception $s){
echo $s->getMessage();
}
?>
This is php.ini
[mail function]
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my sender ID@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=On
extension=php_openssl.dll
And this is sendmail.ini
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
auth_username=my sender ID@gmail.com
auth_password= my ID password
force_sender=my sender ID@gmail.com
NOTE: XAMPP v 3.2.2
NOTE: PHP v 7.0.13