API - port can be omitted in EMAIL_URL (defaults to 25)
This commit is contained in:
parent
33fde0394a
commit
d17626c301
@ -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 SSL: ``smtp://username:password@smtp.example.com:465/?ssl=True``
|
||||||
- with STARTTLS: ``smtp://username:password@smtp.example.com:587/?tls=True``
|
- with STARTTLS: ``smtp://username:password@smtp.example.com:587/?tls=True``
|
||||||
|
|
||||||
|
|
||||||
.. versionadded:: 0.5.3
|
.. versionadded:: 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
|
Map tile server
|
||||||
^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^
|
||||||
|
@ -461,7 +461,10 @@ see <a class="reference external" href="https://docs.sqlalchemy.org/en/13/core/p
|
|||||||
<div class="versionadded">
|
<div class="versionadded">
|
||||||
<p><span class="versionmodified added">New in version 0.5.3.</span></p>
|
<p><span class="versionmodified added">New in version 0.5.3.</span></p>
|
||||||
</div>
|
</div>
|
||||||
<p>Credentials can be omitted: <code class="docutils literal notranslate"><span class="pre">smtp://smtp.example.com:25</span></code></p>
|
<div class="line-block">
|
||||||
|
<div class="line">Credentials can be omitted: <code class="docutils literal notranslate"><span class="pre">smtp://smtp.example.com:25</span></code>.</div>
|
||||||
|
<div class="line">If <code class="docutils literal notranslate"><span class="pre">:<port></span></code> is omitted, the port defaults to 25.</div>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section id="map-tile-server">
|
<section id="map-tile-server">
|
||||||
<h3>Map tile server<a class="headerlink" href="#map-tile-server" title="Permalink to this headline">¶</a></h3>
|
<h3>Map tile server<a class="headerlink" href="#map-tile-server" title="Permalink to this headline">¶</a></h3>
|
||||||
|
@ -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 SSL: ``smtp://username:password@smtp.example.com:465/?ssl=True``
|
||||||
- with STARTTLS: ``smtp://username:password@smtp.example.com:587/?tls=True``
|
- with STARTTLS: ``smtp://username:password@smtp.example.com:587/?tls=True``
|
||||||
|
|
||||||
|
|
||||||
.. versionadded:: 0.5.3
|
.. versionadded:: 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
|
Map tile server
|
||||||
^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^
|
||||||
|
@ -69,7 +69,7 @@ class EmailTemplate:
|
|||||||
class Email:
|
class Email:
|
||||||
def __init__(self, app: Optional[Flask] = None) -> None:
|
def __init__(self, app: Optional[Flask] = None) -> None:
|
||||||
self.host = 'localhost'
|
self.host = 'localhost'
|
||||||
self.port = 1025
|
self.port = 25
|
||||||
self.use_tls = False
|
self.use_tls = False
|
||||||
self.use_ssl = False
|
self.use_ssl = False
|
||||||
self.username = None
|
self.username = None
|
||||||
|
@ -14,7 +14,7 @@ def parse_email_url(email_url: str) -> Dict:
|
|||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
'host': parsed_url.host,
|
'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_tls': True if parsed_url.query == 'tls=True' else False,
|
||||||
'use_ssl': True if parsed_url.query == 'ssl=True' else False,
|
'use_ssl': True if parsed_url.query == 'ssl=True' else False,
|
||||||
'username': credentials[0],
|
'username': credentials[0],
|
||||||
|
@ -12,8 +12,8 @@ class TestEmailUrlParser:
|
|||||||
with pytest.raises(InvalidEmailUrlScheme):
|
with pytest.raises(InvalidEmailUrlScheme):
|
||||||
parse_email_url(url)
|
parse_email_url(url)
|
||||||
|
|
||||||
def test_it_parses_email_url_without_authentication(self) -> None:
|
@staticmethod
|
||||||
url = 'smtp://localhost:25'
|
def assert_parsed_email(url: str) -> None:
|
||||||
parsed_email = parse_email_url(url)
|
parsed_email = parse_email_url(url)
|
||||||
assert parsed_email['username'] is None
|
assert parsed_email['username'] is None
|
||||||
assert parsed_email['password'] 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_tls'] is False
|
||||||
assert parsed_email['use_ssl'] 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:
|
def test_it_parses_email_url(self) -> None:
|
||||||
url = 'smtp://test@example.com:12345678@localhost:25'
|
url = 'smtp://test@example.com:12345678@localhost:25'
|
||||||
parsed_email = parse_email_url(url)
|
parsed_email = parse_email_url(url)
|
||||||
|
Loading…
Reference in New Issue
Block a user