Mail Bundle API¶
flask_unchained.bundles.mail
The Mail Bundle. |
flask_unchained.bundles.mail.config
Default configuration options for the mail bundle. |
|
Development-specific config options for the mail bundle. |
|
Production-specific config options for the mail bundle. |
|
Inherit settings from production. |
|
Test-specific config options for the mail bundle. |
flask_unchained.bundles.mail.extensions
The Mail extension. |
MailBundle¶
Config¶
-
class
flask_unchained.bundles.mail.config.
Config
[source]¶ Default configuration options for the mail bundle.
-
MAIL_SERVER
= '127.0.0.1'¶ The hostname/IP of the mail server.
-
MAIL_PORT
= 25¶ The port the mail server is running on.
-
MAIL_USERNAME
= None¶ The username to connect to the mail server with, if any.
-
MAIL_PASSWORD
= None¶ The password to connect to the mail server with, if any.
-
MAIL_USE_TLS
= False¶ Whether or not to use TLS.
-
MAIL_USE_SSL
= False¶ Whether or not to use SSL.
-
MAIL_DEFAULT_SENDER
= 'Flask Mail <noreply@localhost>'¶ The default sender to use, if none is specified otherwise.
-
MAIL_SEND_FN
(to: Union[str, List[str], None] = None, template: Optional[str] = None, **kwargs)¶ The function to use for sending emails. Defaults to
_send_mail()
. Any customized send function must implement the same function signature:def send_mail(subject_or_message: Optional[Union[str, Message]] = None, to: Optional[Union[str, List[str]] = None, template: Optional[str] = None, **kwargs): # ...
NOTE: subject_or_message is optional because you can also pass subject as a keyword argument, and to is optional because you can also pass recipients as a keyword argument. These are artifacts of backwards-compatibility with vanilla Flask-Mail.
-
MAIL_DEBUG
= 0¶ The debug level to set for interactions with the mail server.
-
MAIL_MAX_EMAILS
= None¶ The maximum number of emails to send per connection with the mail server.
-
MAIL_SUPPRESS_SEND
= False¶ Whether or not to actually send emails, or just pretend to. This is mainly useful for testing.
-
MAIL_ASCII_ATTACHMENTS
= False¶ Whether or not to coerce attachment filenames to ASCII.
-
-
class
flask_unchained.bundles.mail.config.
DevConfig
[source]¶ Development-specific config options for the mail bundle.
-
MAIL_DEBUG
= 1¶ Set the mail server debug level to 1 in development.
-
MAIL_PORT
= 1025¶ In development, the mail bundle is configured to connect to MailHog.
-
The Mail Extension¶
-
class
flask_unchained.bundles.mail.
Mail
[source]¶ The Mail extension:
from flask_unchained.bundles.mail import mail
-
send_message
(subject_or_message: Union[flask_mail.Message, str, None] = None, to: Union[str, List[str], None] = None, **kwargs)[source]¶ Send an email using the send function as configured by
MAIL_SEND_FN
.- Parameters
subject_or_message – The subject line, or an instance of
flask_mail.Message
.to – The message recipient(s).
kwargs – Extra values to pass on to
Message
-