aboutsummaryrefslogtreecommitdiffstats
path: root/blogthon.cgi
diff options
context:
space:
mode:
authorAdrian Vondendriesch <discostu@zoozer.de>2009-07-24 16:12:03 +0200
committerAdrian Vondendriesch <discostu@zoozer.de>2009-07-24 16:12:03 +0200
commit88b49223442d9fcda50066053a6416d4bb139836 (patch)
tree57c8f4abf3cf7e77a3e29a49b42f24abb3534f80 /blogthon.cgi
parent3f632c4575d9492bec4efc2e47200f0ed753c7da (diff)
parenta328abe745ae99435bdc400938eaa62414d601df (diff)
Merge branch 'master' of git@fucktheforce.de:blogthon
Diffstat (limited to 'blogthon.cgi')
-rwxr-xr-xblogthon.cgi25
1 files changed, 24 insertions, 1 deletions
diff --git a/blogthon.cgi b/blogthon.cgi
index 23f1dcc..89594c2 100755
--- a/blogthon.cgi
+++ b/blogthon.cgi
@@ -10,7 +10,7 @@
# Adrian Vondendriesch <disco-stu@disco-stu.de>
# Description: A simple blogging software
-import cgi, os, time, glob, re, md5, sys, random
+import cgi, os, time, glob, re, md5, sys, random, smtplib
import ConfigParser
def generate_uuid(string):
@@ -120,6 +120,21 @@ except: errorpage("comments")
try: newest_first = configuration.get('look', 'newest_first')
except: errorpage("newest_first")
+try: new_comment_mail = configuration.get('smtp', 'new_comment_mail')
+except: errorpage("new_comment_mail")
+
+try: mail_to = configuration.get('smtp', 'mail_to')
+except: errorpage("mail_to")
+
+try: smtp_host = configuration.get('smtp', 'smtp_host')
+except: errorpage("smtp_host")
+
+try: smtp_user = configuration.get('smtp', 'smtp_user')
+except: errorpage("smtp_user")
+
+try: smtp_pass = configuration.get('smtp', 'smtp_pass')
+except: errorpage("smtp_pass")
+
# Read POST Variables
action = cgi.FieldStorage()
month_display = action.getvalue('m')
@@ -181,6 +196,14 @@ if cname and ctext and ctitle:
for line in ctext:
content.write("." + line + "\n")
content.close()
+ # Send mail?
+ if new_comment_mail:
+ msg = 'From: Blogthon\nSubject: New comment on ' + blog_title + '\n\nSomeone wrote a comment to this entry: ' + blog_url + '?p=' + re.sub(' ', '-', ctitle)
+ smtp = smtplib.SMTP(smtp_host)
+ if smtp_user != '' and smtp_pass != '':
+ smtp.login(smtp_user, smtp_pass)
+ smtp.sendmail(blog_title, mail_to, msg)
+ smtp.quit()
# Read entries and store their title and timestamp
entries = []