Created
March 22, 2022 16:30
-
-
Save jimdiroffii/86434f5d45aa26cf79c20771c22fdff0 to your computer and use it in GitHub Desktop.
SMTP Tester in Python
This file contains hidden or 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 | |
def prompt(prompt): | |
return input(prompt).strip() | |
fromaddr = prompt("From: ") | |
toaddrs = prompt("To: ").split() | |
print("Enter message, end with ^D (Unix) or ^Z (Windows):") | |
# Add the From: and To: headers at the start! | |
msg = ("From: %s\r\nTo: %s\r\n\r\n" | |
% (fromaddr, ", ".join(toaddrs))) | |
while True: | |
try: | |
line = input() | |
except EOFError: | |
break | |
if not line: | |
break | |
msg = msg + line | |
print("Message length is", len(msg)) | |
server = smtplib.SMTP('<SMTP Server Address>', 25) | |
server.ehlo() | |
server.starttls() | |
server.set_debuglevel(1) | |
server.sendmail(fromaddr, toaddrs, msg) | |
server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment