PHP has a function that can let you send email. This is the mail() function. This requires three mandatory arguments that specify the recipient’s email address, the subject of the message and the actual message.
This function is like sending automated response to your customers or website viewers. Below are the sample PHP scripts:
$to = “email@example.com,firstname.lastname@example.org”;
$subject = “Test mail”;
$message = “Hello! This is a test email message.”;
$from = “email@example.com”;
$headers = “From:” . $from;
echo “Mail Sent.”;
// the message
$msg = “First line of text\nSecond line of text”;
// use wordwrap() if lines are longer than 70 characters
// send email
These codes will be placed on a file called phpmailer.php or mailer.php, however it will be your discretion on how to name it. Also, change necessary information for the scripts to the correct ones.
If you’re sending through an external server, you can go to this guided link to mail script with external server.