forked from ma6174/webmail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
50 lines (45 loc) · 1.24 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
#coding=utf-8
import web
import urllib
import logging
from sendmail import send_mail
urls = (
# '/(.*)','hello',
'/mailto/(.*)','webmail'
)
app = web.application(urls,globals())
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler('webmail.log')
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(message)s')
fh.setFormatter(formatter)
logger.addHandler(fh)
class webmail:
__doc__ ='''
Send Mail to Anyone!
usage:
http://xxx.com/mailto/{mail_address}/{subject}/{body}
example:
http://xxx.com/mailto/[email protected]/subject/body/
multi-address:
http://xxx.com/mailto/[email protected]/[email protected]/subject/body/
'''
def GET(self,name):
logger.info(name)
info = urllib.unquote(name).split('/')
info = [i for i in info if i != '']
if len(info) < 3:
return webmail.__doc__
try:
print ''
send_mail(info[:-2],info[-2],info[-1])
except:
return 'Failed Send Mail'
print info
render = web.template.render('./')
return render.pages(info[:-2],info[-2],info[-1])
if __name__=='__main__':
app.run()
application = app.wsgifunc()