Notification how-to
How to send email when comments or trackbacks are added.
You can receive email when comment/trackback add. Follow instructions bellow.
- Add Mail Host object.
- In management screen,click contents tab.
- Move into methods folder.
COREBlog calls some notification method in methods folder.
To send email when comment added,add PythonScript named addCommentHook. You need one parameter d. And set Proxy roles for the script.
Body of script is something like...
try:
mailhost=getattr(context, \
context.superValues('Mail Host')[0].id)
except:
raise AttributeError, "Mail Host object cant be found."
to_addr = "your@email.address"
from_addr = "sender@email.address"
mMsg = """To: %s
From: %s
Mime-Version: 1.0
Content-Type: text/plain;
Author :%s
Title :%s
URL :%s
EntryID :%s
Body :
%s""" % (to_addr , from_addr , d["author"] , d["title"] ,\
d["url"] , str(d["parent_id"]) , d["body"])
mTo = to_addr
mFrom = from_addr
mSubj = 'A comment added!'
mailhost.send(mMsg, mTo, mFrom, mSubj)
To send email when comment added,add PythonScript named addTrackbackHook. You need one parameter d. And set Proxy roles for the script.
Body of script is something like...
try:
mailhost=getattr(context, \
context.superValues('Mail Host')[0].id)
except:
raise AttributeError, "cant find a Mail Host object"
to_addr = "your@email.address"
from_addr = "sender@email.address"
mMsg = """To: %s
From: %s
Mime-Version: 1.0
Content-Type: text/plain;
Title ?F%s
URL ?F%s
BlogName ?F%s
Body ?F
%s""" % (to_addr,from_addr,d["title"],d["url"],\
d["blog_name"],d["excerpt"])
mTo = to_addr
mFrom = from_addr
mSubj = 'Trackback added!!'
mailhost.send(mMsg, mTo, mFrom, mSubj)
That's all. Have fun :-).