Send Email on every comment

Jan 29, 2009 at 3:32 PM
Hello,

I would like to have an email sent to me everytime someone replies to a blog post, so I know to go back and read it. It seems pretty simple but really cannot find the setting for it. I do see the email setiing in the control panel, which I have set to no-reply@nomail.com , I figure this is for the contact form, or emails sent to users. I also do not want to display my email anywhere on the blog or site. Any help would be greatly appreciated.

Thanks,
Mark
Feb 3, 2009 at 4:12 PM
Hard to believe no response, I am sure I am missing something here. Wouldn't anyone who has a blog want to be notified by email anytime someone leaves a comment on their blog post ????? Maybe the only difference I am looking for is to not display the persons email that it is sending to, when a comment is left.

Any help ??
Coordinator
Feb 3, 2009 at 7:45 PM
There's already the SendCommentMail extension in BlogEngine.  It can be disabled/enabled on the Extensions tab in the Control Panel.  The code for this is in App_Code\Extensions\SendCommentMail.cs.  It's also necessary that the 'Send comment e-mail' checkbox is checked in the 'E-mail' section on the the Settings tab.

To get the extension to send an email to you, rather than your noreply email address, you can change the line below in SendCommentMail.cs ...

mail.To.Add(BlogSettings.Instance.Email);

... change to ...

mail.To.Add("yourRealEmailAddress@something.com");

While you're there, I'd suggest all changing the "From" line,

string from = comment.Email.Contains("@") ? comment.Email : BlogSettings.Instance.Email;

... change to ...

string from = BlogSettings.Instance.Email;

This would make the From address be your noreply address.  I suggest this since the original line tries to send the email with the commenter's email address as the From address.  Often times mail servers won't send email if the From address is an email account not setup on the mail server.
Feb 6, 2009 at 3:41 PM
Ben,

Thanks for your help, I really appreciate it. The changes seem simple and I see exactly what to do, but it is not sending mail. I made a backup copy of the SendCommentMail.cs, and now have restored that, to go back and start from the beginning, I never verified that worked to start with.

I changed the no-reply email address in the email section under the settings tab, to my email address - now when I click the "test email" button, it sends me an email, works fine, when I go to the site, and use the contact form, it sends me an email, all working fine, but when I leave a comment, it doesnt send an email. I tried using my email and other emails for the form when leaving a comment, and still no luck, no email.

Now I try making the changes one at a time, that you have posted and still no luck. I thought maybe changing the  - string from - would help, but it doesnt.

So basically, I would just like to start by getting the email when a comment is left without anything modified, and right now, it sends email when I do the "test email" button, and when I use the contact form, but not when I leave comments.

Any suggestions ???

Again, Thank you very much for your reply and detailed response.

Coordinator
Feb 6, 2009 at 4:04 PM
I think the problem is the following line in SendCommentMail:

if (post != null && BlogSettings.Instance.SendMailOnComment && !Thread.CurrentPrincipal.Identity.IsAuthenticated)

This last part "!Thread.CurrentPrincipal.Identity.IsAuthenticated", basically says that it will only continue to send the email if the person leaving the comment is NOT logged into the blog at that time.  You're probably logged into your blog (as the admin) when you're leaving the comment, resulting in no email being sent.  This is probably in there so blog owners don't get emails when they (the blog owners) are replying to comments left by other people.

You could try logging out of your blog before leaving a comment to test if this is what the problem is.  You could also remove that last part if you wanted.

... last part removed ...
if (post != null && BlogSettings.Instance.SendMailOnComment)
Feb 6, 2009 at 4:08 PM

How do I edit the top navigation words in link text…

In what file…?

Home , Archive, Contact, Subscribe , Log in

I want to change text for Contact…

Thanks

Greg

Coordinator
Feb 6, 2009 at 4:14 PM
Probably in the site.master file in your theme folder ...
Feb 6, 2009 at 4:53 PM
Ben,

That fixed everything, Thank You very much. Help like this, and such quick responses, is part of what makes BlogEngine such a great product.

Thanks Again,
Mark