PHP Code to send HTML Email or Newsletter of mail
Posted On at by milanLots of time we need to send the newsletter or HTML email to the visitors of our website. Following is the simple PHP code to send HTML newsletter.
//Variables from the HTML form
$message=stripslashes($_POST['newsmsg']);
$subject=$_POST['newssub'];
//headers variable being set
headers="From: sender@site.com\nReply-To: sender@site.com\nContent-Type: text/html";
//Getting all recipient email addresses from db in my case
$subRes=getSubscribe();
//Sending HTML email to each recipient
while($subAry=mysql_fetch_array($subRes))
{
mail($subAry['email'], $subject, $message, "From: $from\nReply-To: $from\nContent-Type: text/html");
}
echo "sucess";
?>