Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add sending email part

  • Loading branch information...
commit 67f294e52dec4aec357b61614a943c2970124753 1 parent 0d4ab40
David Shieh authored

Showing 3 changed files with 15 additions and 2 deletions. Show diff stats Hide diff stats

  1. +1 0  ChangeLog.txt
  2. +2 2 TODO.txt
  3. +12 0 views.py
1  ChangeLog.txt
@@ -5,6 +5,7 @@
5 5 3. 加入pygments作代码高亮的处理
6 6 4. 模板引擎切换到jinja2上
7 7 5. 加入一个随机文章的功能
  8 + 6. 加入了发送邮件的功能
8 9
9 10 ### 0.3 主要是修复bug ###
10 11 1. 部分使用了jinja2(即部分页面没有更换引擎, 不能正常显示)
4 TODO.txt
... ... @@ -1,5 +1,5 @@
1 1 1. 全部页面都切换到jinja2上(Done)
2   -2. 加入一个random entries的功能, 放在右侧
  2 +2. 加入一个random entries的功能, 放在右侧(Done, 放在上侧了)
3 3 3. 优化程序结构
4 4 4. 加入文章搜索功能
5   -5. 使用pygments处理代码高亮
  5 +5. 使用pygments处理代码高亮(Done)
12 views.py
@@ -89,6 +89,18 @@ def POST(self, slug):
89 89 entry.commentNum = entry.commentNum + 1
90 90 entry.viewNum = entry.viewNum - 1
91 91 web.ctx.orm.add(comment)
  92 + emails = ['mykingheaven@gmail.com']
  93 + message = u'<p>您在&lt;泥泞的沼泽&gt;上回复的日志 "' + entry.title + u'" 又有新的回复了, 请您去看看.</p><p>' \
  94 + u'<a href="http://davidx.me/entry/' + slug + u'/#comments">点击查看回复</a></p>'
  95 + for c in entry.comments:
  96 + emails.append(c.email)
  97 + for e in set(emails):
  98 + try:
  99 + web.sendmail('admin@davidx.me', e,
  100 + u'您在"泥泞的沼泽"上回复的日志又有新的回复了!', message,
  101 + headers={'Content-Type':'text/html;charset=utf-8'})
  102 + except:
  103 + pass
92 104 raise web.seeother('/entry/%s/' % slug)
93 105 else:
94 106 d['p'] = p

0 comments on commit 67f294e

Please sign in to comment.
Something went wrong with that request. Please try again.