jonnsl / sliComments

Comments component for Joomla! 1.6
GNU General Public License v3.0
16 stars 5 forks source link

E-Mail new comments #35

Open rgblogs opened 12 years ago

rgblogs commented 12 years ago

Hi

Is there any way to get email notification of any new comment?

Thanks

jonnsl commented 12 years ago

There is no way to do that in the current version but a notification system is planned for the version 1.4

adamgatt commented 12 years ago

I would also like an email notification for new comments. Happy to see it is planned in a future release.

In the meantime I've inserted this block of code into com_slicomments/controllers/comments.raw.php on line 47.

/*

Send email notification that a new comment has been posted

*/

$to_address = "youremail@yourdomain.com"; $from_name = "Your Website Name"; $from_address = "website@yourdomain.com";

$subject = "Article Comment"; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= "From: =?UTF-8?B?". base64_encode($from_name) ."?= <$from_address>\r\n"; $headers .= "Bcc: " . "\r\n" . "X-Mailer: php";

$emailContent = "

A user has posted a new comment on the yourdomain.com Website. This comment is currently pending and will not be published until it is authorised by an Administrator. Please login to the Administration area of the website and approve or delete this comment.

The details of the comment are:

This notifcation was auto-generated by the <a href=\"http://www.yourdomain.com\">yourdomain.com Website - If this was sent to you in error or there are any problems please email <a href=\"mailto:youremail@yourdomain.com\">youremail@yourdomain.com.


";

mail($to_address, $subject, $emailContent, $headers, "-f $from_address");

/*

End email notification block.

*/

With my limited PHP and Joomla knowledge I can only figure out how to include the Comment Author's name in the email notification. =( I hope someone finds this useful.

gquadro commented 10 years ago

A possible plugin implementation for this is in pull request #54