diff --git a/docs/_sources/installation.rst.txt b/docs/_sources/installation.rst.txt index aff086ac..e4d09d79 100644 --- a/docs/_sources/installation.rst.txt +++ b/docs/_sources/installation.rst.txt @@ -209,9 +209,11 @@ To send emails, a valid ``EMAIL_URL`` must be provided: - with SSL: ``smtp://username:password@smtp.example.com:465/?ssl=True`` - with STARTTLS: ``smtp://username:password@smtp.example.com:587/?tls=True`` + .. versionadded:: 0.5.3 -Credentials can be omitted: ``smtp://smtp.example.com:25`` +| Credentials can be omitted: ``smtp://smtp.example.com:25``. +| If ``:`` is omitted, the port defaults to 25. Map tile server ^^^^^^^^^^^^^^^ diff --git a/docs/installation.html b/docs/installation.html index c1a32e75..bef7f4a5 100644 --- a/docs/installation.html +++ b/docs/installation.html @@ -461,7 +461,10 @@ see

New in version 0.5.3.

-

Credentials can be omitted: smtp://smtp.example.com:25

+
+
Credentials can be omitted: smtp://smtp.example.com:25.
+
If :<port> is omitted, the port defaults to 25.
+

Map tile serverΒΆ

diff --git a/docsrc/source/installation.rst b/docsrc/source/installation.rst index aff086ac..e4d09d79 100644 --- a/docsrc/source/installation.rst +++ b/docsrc/source/installation.rst @@ -209,9 +209,11 @@ To send emails, a valid ``EMAIL_URL`` must be provided: - with SSL: ``smtp://username:password@smtp.example.com:465/?ssl=True`` - with STARTTLS: ``smtp://username:password@smtp.example.com:587/?tls=True`` + .. versionadded:: 0.5.3 -Credentials can be omitted: ``smtp://smtp.example.com:25`` +| Credentials can be omitted: ``smtp://smtp.example.com:25``. +| If ``:`` is omitted, the port defaults to 25. Map tile server ^^^^^^^^^^^^^^^ diff --git a/fittrackee/emails/email.py b/fittrackee/emails/email.py index 7c95fed9..562fdbc0 100644 --- a/fittrackee/emails/email.py +++ b/fittrackee/emails/email.py @@ -69,7 +69,7 @@ class EmailTemplate: class Email: def __init__(self, app: Optional[Flask] = None) -> None: self.host = 'localhost' - self.port = 1025 + self.port = 25 self.use_tls = False self.use_ssl = False self.username = None diff --git a/fittrackee/emails/utils_email.py b/fittrackee/emails/utils_email.py index 5ce18a5f..f6a58f42 100644 --- a/fittrackee/emails/utils_email.py +++ b/fittrackee/emails/utils_email.py @@ -14,7 +14,7 @@ def parse_email_url(email_url: str) -> Dict: ) return { 'host': parsed_url.host, - 'port': parsed_url.port, + 'port': 25 if parsed_url.port is None else parsed_url.port, 'use_tls': True if parsed_url.query == 'tls=True' else False, 'use_ssl': True if parsed_url.query == 'ssl=True' else False, 'username': credentials[0], diff --git a/fittrackee/tests/emails/test_email_utils.py b/fittrackee/tests/emails/test_email_utils.py index 4202a31f..c543246f 100644 --- a/fittrackee/tests/emails/test_email_utils.py +++ b/fittrackee/tests/emails/test_email_utils.py @@ -12,8 +12,8 @@ class TestEmailUrlParser: with pytest.raises(InvalidEmailUrlScheme): parse_email_url(url) - def test_it_parses_email_url_without_authentication(self) -> None: - url = 'smtp://localhost:25' + @staticmethod + def assert_parsed_email(url: str) -> None: parsed_email = parse_email_url(url) assert parsed_email['username'] is None assert parsed_email['password'] is None @@ -22,6 +22,14 @@ class TestEmailUrlParser: assert parsed_email['use_tls'] is False assert parsed_email['use_ssl'] is False + def test_it_parses_email_url_without_port(self) -> None: + url = 'smtp://localhost' + self.assert_parsed_email(url) + + def test_it_parses_email_url_without_authentication(self) -> None: + url = 'smtp://localhost:25' + self.assert_parsed_email(url) + def test_it_parses_email_url(self) -> None: url = 'smtp://test@example.com:12345678@localhost:25' parsed_email = parse_email_url(url)