| 1 |
.. _connection-types: |
| 2 |
|
| 3 |
TLS, SSL & STARTTLS |
| 4 |
=================== |
| 5 |
|
| 6 |
aiosmtplib supports the three main types of encryption used by SMTP servers: |
| 7 |
|
| 8 |
1. Plaintext (default port 25). The connection is entirely unencrypted. |
| 9 |
Most authentication methods will not be supported by servers |
| 10 |
when using an unencrypted connection. Best suited for connecting to a |
| 11 |
server running locally or for testing. |
| 12 |
2. TLS/SSL encrypted (default port 465). In this case the TLS handshake |
| 13 |
occurs when the connection is established, and all traffic is encrypted. |
| 14 |
This type of connection should generally be used where available. |
| 15 |
3. STARTTLS (default port 587). When using STARTTLS, an initial unencrypted |
| 16 |
connection is made, EHLO/HELO greetings are exchanged, and the connection |
| 17 |
is upgraded in place once the client requests it by sending the STARTTLS |
| 18 |
command. Most servers require an upgrade before allowing AUTH commands. |
| 19 |
|
| 20 |
.. tip:: By default, if aiosmtplib will connect in plaintext and upgrade the |
| 21 |
connetion using STARTTLS if the server supports it. If you want to opt out |
| 22 |
of upgrades even if the server supports them, pass a ``start_tls`` value of |
| 23 |
``False``. |