Comment Notification

This is the right place to report general bugs, make suggestions or ask for help.
Post Reply
User avatar
WineMan
Posts: 107
Joined: Tue Sep 01, 2020 5:03 pm

Comment Notification

Post by WineMan » Tue Jul 25, 2023 5:17 pm

Currently, Flatpress will send the admin an email notification of any comment posted to any of the blog posts.

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);
			}
Obviously, you need to change the $headers and Reply-To, information to match your information. I have also commented out that portion of the comments.php file that is not used. Hope this helps in case you want to use this option.

User avatar
Arvid
FlatPress Coder
Posts: 576
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: Comment Notification

Post by Arvid » Sat Oct 28, 2023 12:47 pm

Nice one! :)

The only downside is: comments.php will be overwritten with the next FlatPress update, so you'll have to keep this change in mind and re-add the code afterwards.

All the best,
Arvid

User avatar
WineMan
Posts: 107
Joined: Tue Sep 01, 2020 5:03 pm

Re: Comment Notification

Post by WineMan » Sat Oct 28, 2023 4:47 pm

Thanks for the heads up...when can we expect the next version to be released?

User avatar
Arvid
FlatPress Coder
Posts: 576
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: Comment Notification

Post by Arvid » Sun Oct 29, 2023 1:53 pm

I wrote a few words on the current development status on the project blog: https://www.flatpress.org/2023/10/29/lo ... nt-status/

All the best,
Arvid

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests