I wanted to send an email notification to any subscriber of my blog, and I did that by changing the code in the comments.php file to the following. This starts at line 228 and ends at line 249 in my comments.php file. I am referring to the comments.php file in the root of the flatpress. Please note that I have set up a Subscribe to my blog module that inserts email addresses to a data.txt file in a folder called newsletter. The text file is set up as follows:
myemail@email.com,youremail@email.com,hisemail@email.com, etc. Your last email address in the text file should end with a comma (,)
Code: Select all
//$email_to = "you@email.com";
$email_subject = "Comment Submission";
$headers = "From: Your Blog Title <yourfrom@email.com>\n" .
"Reply-To: Blogmaster <replyto@email.com>\n" .
"MIME-Version: 1.0\n" . "Content-Type: text/plain; charset=iso-8859-1";
$email_message = "$mail";
$emails = file('newsletter/data.txt', FILE_IGNORE_NEW_LINES);
$x = 1;
foreach ($emails as $email) {
$mail_sent = @mail($email, $email_subject, $email_message, $headers);
//if($mail_sent) {
//echo "Email sent to all subscribers";
//} else {
//echo "Email not sent";
//}
//echo $mail_sent ? $x . ', ' : '0, ';
$x++;
}
//@mail($email_to, $email_subject, $email_message);
}