Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/local/bin/python
- SMTPserver = 'email-smtp.us-west-2.amazonaws.com'
- sender = 'smastrian@ashion.com'
- destination = ['smastrian@ashion.com']
- USERNAME = "AKIAJLHGQS6ZEH4DH3OA"
- PASSWORD = "Ahh497hW/gxLbw/ml4UWMdwYUn5sywwlPuQgu+XdVP0A"
- # typical values for text_subtype are plain, html, xml
- text_subtype = 'plain'
- content="""\
- Test message
- """
- subject="Sent from Python"
- import sys
- import os
- import re
- from smtplib import SMTP_SSL as SMTP # this invokes the secure SMTP protocol (port 465, uses SSL)
- # from smtplib import SMTP # use this for standard SMTP protocol (port 25, no encryption)
- # old version
- # from email.MIMEText import MIMEText
- from email.mime.text import MIMEText
- try:
- msg = MIMEText(content, text_subtype)
- msg['Subject']= subject
- msg['From'] = sender # some SMTP servers will do this automatically, not all
- conn = SMTP(SMTPserver)
- conn.set_debuglevel(False)
- conn.login(USERNAME, PASSWORD)
- try:
- conn.sendmail(sender, destination, msg.as_string())
- finally:
- conn.quit()
- except:
- sys.exit( "mail failed; %s" % "CUSTOM_ERROR" ) # give an error message
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement