Send mail with PHP

The mail function of php can be used to send mails.

E.g.

$to = 'recipient@example.com';
$subject = 'Hello This is the Subject';
$body = 'Hello This is the Body';
if (mail($to, $subject, $body))
{
echo 'Message Delivered';
}
else
{
echo 'Message delivery failed';
}

Additional headers can be set like this :

$headers = 'From: abcd@example.com' . "rn" .
'Reply-To: abcd@example.com' . "rn" .
'X-Mailer: PHP/' . phpversion();

Popularity: 1% [?]

Leave a Reply