PHP allows you to send e-mails directly from a script. The PHP mail() function is used to send emails from inside a script.
mail($to, $subject, $message, $headers);
As you can see above, the mail function has four parameters.
* $to – the recipients email address
* $subject – the subject of the email.
* $message – the email message to be sent.
* $headers – the header contains information such as the format of the email (plain text or HTML), senders name and email, reply to address, CC and BCC.
PHP Simple E-Mail
The following code will send out a plain text email using the PHP built in mail() function.
$to = "firstname.lastname@example.org";
$subject = "Test mail";
$message = "Hai! This is a simple plain text message.";
$from = "email@example.com";
$headers = "From:" . $from;
echo "Mail Sent.";