1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-26 02:57:04 +00:00
mailinabox/tests/smtp_submission.py

23 lines
465 B
Python
Raw Normal View History

2013-08-31 14:46:25 +00:00
#!/usr/bin/python3
import smtplib, sys
2013-08-21 13:37:33 +00:00
2013-08-31 14:46:25 +00:00
if len(sys.argv) < 3:
print("Usage: tests/smtp_submission.py host email.from pw email.to")
sys.exit(1)
2013-08-21 13:37:33 +00:00
2013-08-31 14:46:25 +00:00
host, fromaddr, pw, toaddr = sys.argv[1:5]
2013-08-21 13:37:33 +00:00
msg = """From: %s
To: %s
2013-08-31 14:46:25 +00:00
Subject: SMTP server test
2013-08-21 13:37:33 +00:00
2013-08-31 14:46:25 +00:00
This is a test message.""" % (fromaddr, toaddr)
2013-08-21 13:37:33 +00:00
2013-08-31 14:46:25 +00:00
server = smtplib.SMTP(host, 587)
2013-08-21 13:37:33 +00:00
server.set_debuglevel(1)
server.starttls()
2013-08-31 14:46:25 +00:00
server.login(fromaddr, pw)
server.sendmail(fromaddr, [toaddr], msg)
2013-08-21 13:37:33 +00:00
server.quit()
2013-08-31 14:46:25 +00:00