1
1
"""
2
- Module provides an interface to the system's sendmail client.
2
+ flask_sendmail
3
+ ~~~~~~~~~~~~~~
4
+
5
+ Module provides an interface to the system's sendmail client.
3
6
4
- It's based heavily off of Flask-Mail (originaly by danjac),
5
- and owes a majority of its code to him .
7
+ It's based heavily off of Flask-Mail (written by danjac),
8
+ and owes a majority of its code to it .
6
9
10
+ It's also designed to be a nearly complete drop-in replacement
11
+ for Flask-Mail.
12
+
13
+ :copyright: (c) 2012 by Anthony Ford.
14
+ :license: None, see LICENSE for more details.
7
15
"""
8
- from flask . ext . sendmail . message import Message
9
- from flask . ext . sendmail .connection import Connection
16
+ from flask_sendmail . message import Message , BadHeaderError
17
+ from flask_sendmail .connection import Connection
10
18
11
- class Mailer (object ):
19
+ class Mail (object ):
12
20
13
21
def __init__ (self ,app = None ):
14
22
if app is not None :
@@ -18,7 +26,7 @@ def init_app(self, app):
18
26
"""
19
27
Initializes your mail settings from app.config
20
28
21
- Can be used to set up the Mailer at configuration time
29
+ Can be used to set up Mail at configuration time
22
30
23
31
:param app: Flask application instance
24
32
"""
@@ -28,19 +36,19 @@ def init_app(self, app):
28
36
self .mailer_flags = app .config .get ('MAIL_MAILER_FLAGS' ,'-t' )
29
37
self .suppress = app .config .get ('MAIL_SUPPRESS_SEND' , False )
30
38
self .fail_silently = app .config .get ('MAIL_FAIL_SILENTLY' , True )
31
-
39
+ self . max_emails = None
32
40
self .suppress = self .suppress or app .testing
33
41
self .app = app
34
42
35
- #register extenshion with app
43
+ #register extension with app
36
44
app .extensions = getattr (app , 'extensions' , {})
37
45
app .extensions ['sendmail' ] = self
38
46
39
47
def send (self ,message ):
40
48
"""
41
49
Sends message through system's sendmail client.
42
50
43
- :param message: Mailer Message instance
51
+ :param message: Mail Message instance
44
52
"""
45
53
46
54
with self .connect () as connection :
@@ -60,4 +68,4 @@ def connect(self, max_emails=None):
60
68
Opens a connection to the system's sendmail client.
61
69
"""
62
70
63
- return Connection (self , max_email )
71
+ return Connection (self , max_emails )
0 commit comments