forked from equeny/tornadomail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
33 lines (23 loc) · 751 Bytes
/
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
import contextlib
from tornado import ioloop
from tornadomail import send_mail
from tornadomail.backends.smtp import EmailBackend
from tornado import stack_context
def callback(*args, **kwargs):
ioloop.IOLoop.instance().stop()
print 'Successfully sended'
def error_handler(e, msg, traceback):
print 'Error:'
print msg
ioloop.IOLoop.instance().stop()
return True
with stack_context.ExceptionStackContext(error_handler):
send_mail(
'subject', 'message', 'robo@djangostars.com',
['anton.agafonov@gmail.com'], callback=callback,
connection=EmailBackend(
'smtp.gmail.com', 587, 'robo@djangostars.com', 'fakeuser2',
True
)
)
ioloop.IOLoop.instance().start()