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 = hpxyz123@gmail.com
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= hpxyz123@gmail.com
auth_password= hpxyz@123
force_sender= hpxyz123@gmail.com
<?php
$to_email = "edu@teknowize.com"; //Reciepient mail
$subject = "Test mail";
$body = "hello, this is test mail ";
$from_mail = "hpxyz123@gmail.com"; // your mail
if (mail($to_email, $subject, $body, $from_mail)) {
echo "Email successfully sent to $to_email...";
} else {
echo "Email sending failed...";
}
?>
Result–