How do I send mail from my website using PHP?


You can send emails directly from your PHP website hosted on your shared Linux (Apache) package. Below you can find a sample code to do so. As “From” address you fill in an email address of your own domain name f.i. webmaster@your-domain.be.

$to = ’nobody@example.com’;
$subject = ’the subject’;
$message = ’hello’;
$headers = ’From: webmaster@example.com’ . " " .
’Reply-To: webmaster@example.com’ . " " .
’X-Mailer: PHP/’ . phpversion();

mail($to, $subject, $message, $headers, ’-f webmaster@example.com’);
?>



Article Number: 1285
Posted: Mon, Nov 9, 2009 2:40 PM
Last Updated: Wed, May 13, 2015 1:54 PM
Posted: Nick Corne [nick.corne@hostbasket.com]

Online URL: https://onlinehelp.cloud.telenet.be/article.php?id=1285