How to send email using PHP mail() function

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 <>\r\n";
$headers .= 'Cc:' . "\r\n";
$headers .= 'Bcc:' . "\r\n";
$headers .= "Reply-To:\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";

For the “from” email, some hosting requires you to use only registered email address in your hosting/domain.

Leave a Reply

Your email address will not be published. Required fields are marked *