forked from mozilla/stoneridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sremailer.py
35 lines (26 loc) · 855 Bytes
/
sremailer.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
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.
import bottle
import logging
import stoneridge
@bottle.post('/email')
def email():
logging.debug('handling email')
r = bottle.request.forms
to = r.get('to')
logging.debug('to: %s' % (to,))
subject = r.get('subject')
logging.debug('subject: %s' % (subject,))
msg = r.get('message')
logging.debug('message: %s' % (msg,))
stoneridge.sendmail(to, subject, msg)
def daemon():
stoneridge.StreamLogger.bottle_inject()
bottle.run(host='0.0.0.0', port=2255)
@stoneridge.main
def main():
parser = stoneridge.DaemonArgumentParser()
parser.parse_args()
parser.start_daemon(daemon)