How to send email using PHP mail() function
June 4th, 2009
No comments
Here’s a quick way to send an email. You only need one line for that. I always use this script to send an alert on any event triggered. Let say somebody just make a payment on your site.
$headers = "From: sendername <sender@example.com>\r\n"; $headers .= "Reply-To: sender@example.com\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; mail('recipient@example.com','Subject','Message',$headers);
For the “from” email, some hosting requires you to use only registered email address in your hosting/domain.