Skip to content

Commit 106583a

Browse files
authored
Flip back to Flask-Mail as the default mailer. (#1117)
Flask-Mail is again supported and part of Pallets-Eco. Flask-Mailman is still supported as before.
1 parent 83e53fe commit 106583a

23 files changed

+141
-156
lines changed

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Version 5.7.0
88

99
Released XXX
1010

11+
This release is a set of small backward incompatible changes. Please read these notes carefully.
12+
1113
Fixes
1214
+++++
1315
- (:issue:`1109`) Fix broken link in docs and improve docstrings/typing for util classes.
@@ -17,12 +19,18 @@ Docs and Chores
1719
- (:pr:`1106`) Drop support for Python 3.9. This removes the dependency on importlib_resources,
1820
updates pypy to 3.10, and uses 3.12 as base python for tests/tox.
1921
- (:pr:`1112`) Flip :py:data:`SECURITY_USE_REGISTER_V2` default to ``True``.
22+
- (:pr:`xx`) Flip default mail package back to Flask-Mail (from Flask-Mailman).
2023

2124
Backwards Compatibility Concerns
2225
+++++++++++++++++++++++++++++++++
2326
As mentioned above - the default RegisterForm is now the new RegisterFormV2 - Please read :ref:`register_form_migration`.
2427
Flask-Security will emit a DeprecationWarning if the :py:data:`SECURITY_USE_REGISTER_V2` is set to False.
2528

29+
In 5.0 we changed the default mailer package to Flask-Mailman since Flask-Mail was no longer supported.
30+
Flask-Mail is again supported and is part of Pallets-Eco. Both packages are still supported based on which one
31+
an application initializes. The only backwards compatibility concern is that if you use the setup extras 'common',
32+
it will install Flask-Mail rather than Flask-Mailman.
33+
2634
Version 5.6.2
2735
-------------
2836

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ maintenance of related projects. If you are interested in helping maintain
5555
this project, please reach out on `the Pallets Discord server <https://discord.gg/pallets>`.
5656

5757
Goals
58-
+++++
58+
-----
5959

6060
* Use `OWASP <https://github.com/OWASP/ASVS>`_ to guide best practice and default configurations.
6161
* Be more opinionated and 'batteries' included by reducing reliance on abandoned projects and
@@ -73,7 +73,7 @@ Goals
7373

7474

7575
Contributing
76-
++++++++++++
76+
------------
7777
Issues and pull requests are welcome. Other maintainers are also welcome.
7878
Please consult these `contributing`_ guidelines.
7979

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Many of these features are made possible by integrating various Flask extensions
3232
and libraries. They include:
3333

3434
* `Flask-Login <https://flask-login.readthedocs.org/en/latest/>`_
35-
* `Flask-Mailman <https://pypi.org/project/Flask-Mailman/>`_
35+
* `Flask-Mail <https://pypi.org/project/Flask-Mail/>`_
3636
* `Flask-Principal <https://pypi.org/project/Flask-Principal/>`_
3737
* `Flask-WTF <https://pypi.org/project/Flask-WTF/>`_
3838
* `itsdangerous <https://pypi.org/project/itsdangerous/>`_

docs/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Supported extras are:
2828

2929
* ``babel`` - Translation services. It will install babel and Flask-Babel.
3030
* ``fsqla`` - Use flask-sqlalchemy and sqlalchemy as your storage interface.
31-
* ``common`` - Install Flask-Mailman, argon2 (the default password hash), and bleach.
31+
* ``common`` - Install Flask-Mail, argon2 (the default password hash), bcrypt (old commonly used password hash) and bleach.
3232
* ``mfa`` - Install packages used for multi-factor (two-factor, unified signin, WebAuthn):
3333
cryptography, qrcode, phonenumberslite (note that for SMS you still need
3434
to pick an SMS provider and install appropriate packages), and webauthn.

docs/quickstart.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ There are some complete (but simple) examples available in the *examples* direct
77
.. note::
88
The below quickstarts are just that - they don't enable most of the features (such as registration, reset, etc.).
99
They basically create a single user, and you can login as that user... that's it.
10-
As you add more features, additional packages (e.g. Flask-Mailman, Flask-Babel, qrcode) might be required
10+
As you add more features, additional packages (e.g. Flask-Mail, Flask-Babel, qrcode) might be required
1111
and will need to be added to your requirements.txt (or equivalent) file.
1212
Flask-Security does some configuration validation and will output error messages to the console
1313
for some missing packages.
@@ -561,15 +561,15 @@ Mail Configuration
561561

562562
Flask-Security integrates with an outgoing mail service via the ``mail_util_cls`` which
563563
is part of initial configuration. The default class :class:`flask_security.MailUtil` utilizes the
564-
`Flask-Mailman <https://pypi.org/project/flask-mailman/>`_ package. Be sure to add flask_mailman to
565-
your requirements.txt. The older and no longer maintained package `Flask-Mail <https://pypi.org/project/Flask-Mail/>`_
566-
is also (still) supported.
564+
`Flask-Mail <https://pypi.org/project/flask-mail/>`_ package. Be sure to add flask_mail to
565+
your requirements.txt. The Django inspired package `Flask-Mailman <https://pypi.org/project/Flask-Mailman/>`_
566+
is also supported.
567567

568568
The following code illustrates a basic setup, which could be added to
569569
the basic application code in the previous section::
570570

571571
# At top of file
572-
from flask_mailman import Mail
572+
from flask_mail import Mail
573573

574574
# After 'Create app'
575575
app.config['MAIL_SERVER'] = 'smtp.example.com'
@@ -579,9 +579,9 @@ the basic application code in the previous section::
579579
app.config['MAIL_PASSWORD'] = 'password'
580580
mail = Mail(app)
581581

582-
To learn more about the various Flask-Mailman settings to configure it to
582+
To learn more about the various Flask-Mail settings to configure it to
583583
work with your particular email server configuration, please see the
584-
`Flask-Mailman documentation <https://waynerv.github.io/flask-mailman/>`_.
584+
`Flask-Mail documentation <https://flask-mail.readthedocs.io/en/latest/>`_.
585585

586586
.. _proxy-configuration:
587587

docs/two_factor_configurations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ possible using SQLAlchemy:
3838
from flask_sqlalchemy import SQLAlchemy
3939
from flask_security import Security, SQLAlchemyUserDatastore, \
4040
UserMixin, RoleMixin, auth_required
41-
from flask_mailman import Mail
41+
from flask_mail import Mail
4242

4343
# Create app
4444
app = Flask(__name__)

flask_security/mail_util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
55
Utility class providing methods for validating, normalizing and sending emails.
66
7-
:copyright: (c) 2020-2024 by J. Christopher Wagner (jwag).
7+
:copyright: (c) 2020-2025 by J. Christopher Wagner (jwag).
88
:license: MIT, see LICENSE for more details.
99
10-
While this default implementation uses Flask-Mailman - we want to make sure that
10+
While this default implementation uses Flask-Mail - we want to make sure that
1111
Flask-Mailman isn't REQUIRED (if this implementation isn't used).
1212
"""
1313

@@ -79,7 +79,7 @@ def send_mail(
7979
so we cast to str() here to force localization.
8080
"""
8181

82-
if current_app.extensions.get("mailman", None):
82+
if current_app.extensions.get("mailman", None): # pragma: no cover
8383
from flask_mailman import EmailMultiAlternatives, Mail
8484

8585
# Flask-Mailman doesn't appear to take a tuple - a bug has been filed
@@ -104,7 +104,7 @@ def send_mail(
104104
msg.attach_alternative(html, "text/html")
105105
msg.send()
106106

107-
elif current_app.extensions.get("mail", None): # pragma: no cover
107+
elif current_app.extensions.get("mail", None):
108108
from flask_mail import Message
109109

110110
# In Flask-Mail, sender can be a two element tuple -- (name, address)

mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ignore_errors = True
2525

2626
[mypy-quart.*]
2727
ignore_missing_imports = True
28-
[mypy-flask_mail.*]
28+
[mypy-flask_mailman.*]
2929
ignore_missing_imports = True
3030
[mypy-twilio.*]
3131
ignore_missing_imports = True

pyproject-too.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ dependencies = [
5050
[project.optional-dependencies]
5151
babel = ["babel>=2.12.1", "flask_babel>=4.0.0"]
5252
fsqla = ["flask_sqlalchemy>=3.1.0", "sqlalchemy>=2.0.18", "sqlalchemy-utils>=0.41.1"]
53-
common = ["argon2_cffi>=21.3.0", "bcrypt>=4.0.1", "flask_mailman>=0.3.0", "bleach>=6.0.0"]
53+
common = ["argon2_cffi>=21.3.0", "bcrypt>=4.0.1", "flask_mail>=0.10.0", "bleach>=6.0.0"]
5454
mfa = ["cryptography>=40.0.2", "qrcode>=7.4.2", "phonenumberslite>=8.13.11", "webauthn>=2.0.0"]
5555
low = [
5656
# Lowest supported versions
5757
"Flask==3.0.0",
5858
"Flask-SQLAlchemy==3.1.0",
5959
"Flask-SQLAlchemy-Lite==0.1.0;python_version>='3.10'",
6060
"Flask-Babel==4.0.0",
61-
"Flask-Mailman==0.3.0",
61+
"Flask-Mail==0.10.0",
6262
"Flask-Login==0.6.3",
6363
"Flask-WTF==1.1.2",
6464
"peewee==3.17.9",

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ dependencies = [
5050
[project.optional-dependencies]
5151
babel = ["babel>=2.12.1", "flask_babel>=4.0.0"]
5252
fsqla = ["flask_sqlalchemy>=3.1.0", "sqlalchemy>=2.0.18", "sqlalchemy-utils>=0.41.1"]
53-
common = ["argon2_cffi>=21.3.0", "bcrypt>=4.0.1", "flask_mailman>=0.3.0", "bleach>=6.0.0"]
53+
common = ["argon2_cffi>=21.3.0", "bcrypt>=4.0.1", "flask_mail>=0.10.0", "bleach>=6.0.0"]
5454
mfa = ["cryptography>=40.0.2", "qrcode>=7.4.2", "phonenumberslite>=8.13.11", "webauthn>=2.0.0"]
5555
low = [
5656
# Lowest supported versions
5757
"Flask==3.0.0",
5858
"Flask-SQLAlchemy==3.1.0",
5959
"Flask-SQLAlchemy-Lite==0.1.0;python_version>='3.10'",
6060
"Flask-Babel==4.0.0",
61-
"Flask-Mailman==0.3.0",
61+
"Flask-Mail==0.10.0",
6262
"Flask-Login==0.6.3",
6363
"Flask-WTF==1.1.2",
6464
"peewee==3.17.9",

0 commit comments

Comments
 (0)