Created
February 12, 2024 16:47
-
-
Save athoune/9f68c6fa914b42480f573b2823ad922e to your computer and use it in GitHub Desktop.
Test your SMTP settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smtplib | |
import base64 | |
user = 'bob' | |
password = 'password' | |
# The server handle TLS connection, not the boring STARTTLS upgrade | |
server = smtplib.SMTP_SSL(host='smtp.example.com', timeout=5) | |
server.ehlo() # the server say its name and handled commands, you should see "AUTH PLAIN" | |
# The RFC for SMTP doesn't say wich text encoding must be used, smtplib use low ASCII, lets forge the command | |
server.docmd("AUTH PLAIN", b64encode(f"\0{user}\0{password}".encode("utf8")).decode("ascii")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment