Last active
August 27, 2019 11:46
-
-
Save selivan/00faa1d305c5d6b5ba93157efaf2469f to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
import sys | |
import os | |
import smtplib | |
from email.mime.text import MIMEText | |
mail_host = 'email-smtp.eu-west-1.amazonaws.com' | |
mail_port = 465 | |
use_starttls = False | |
user = 'XXXXXXXXXXXXXXXXXXXX' | |
password = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY' | |
msg = 'Hello! Does it work?' | |
subj = 'smtp send test' | |
mail_from = '[email protected]' | |
mail_to = ['[email protected]'] | |
# AWS SES test simulator: | |
# https://docs.aws.amazon.com/ses/latest/DeveloperGuide/mailbox-simulator.html | |
#mail_to = ['[email protected]'] | |
#mail_to = ['[email protected]'] | |
#mail_to = ['[email protected]'] | |
#mail_to = ['[email protected]'] | |
#mail_to = ['[email protected]'] | |
if __name__ == "__main__": | |
message = MIMEText(msg, 'plain') | |
message['Subject'] = subj | |
message['From'] = mail_from | |
print("Message:") | |
print(message.as_string()) | |
print("Trying to send...") | |
if use_starttls: | |
conn = smtplib.SMTP(host=mail_host, port=mail_port) | |
conn.starttls() | |
else: | |
conn = smtplib.SMTP_SSL(host=mail_host, port=mail_port) | |
conn.login(user=user, password=password) | |
conn.send_message(from_addr=mail_from, to_addrs=mail_to, msg=message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Moved here:
https://github.com/selivan/smtp-test
Because it's easy to remember repository name, and impossible to remember gist number.