In this article we will learn how to send email using PHP and MySQL from localhost.
Now follow all the below steps to send email in PHP.
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = [email protected]
sendmail_path = "\"C:\xampp\sendmail\
sendmail.exe\" -t"
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
debug_logfile=debug.log
auth_username= [email protected]
auth_password= [email protected]
force_sender= [email protected]
<?php
$to_email = "[email protected]"; //Reciepient mail
$subject = "Test mail";
$body = "hello, this is test mail ";
$from_mail = "[email protected]"; // your mail
if (mail($to_email, $subject, $body, $from_mail)) {
echo "Email successfully sent to $to_email...";
} else {
echo "Email sending failed...";
}
?>
Result–