Skip to content

Instantly share code, notes, and snippets.

@j33ty
Created January 26, 2019 16:15
Show Gist options
  • Save j33ty/e3c7eec954ebdacb0047899975c72bb9 to your computer and use it in GitHub Desktop.
Save j33ty/e3c7eec954ebdacb0047899975c72bb9 to your computer and use it in GitHub Desktop.
Send mail from terminal via any Mail Service using their API keys. This is for testing multiple Mail providers during outage.
import smtplib
from email.mime.text import MIMEText
msg = MIMEText('Loved your locker room talk!')
msg['Subject'] = 'Not so confidential stuff here'
msg['From'] = 'pladimir.vutin@russia.com'
msg['To'] = 'tonald.dump@us.com'
s = smtplib.SMTP('smtp.sendgrid.net', 465)
s.starttls()
s.login('apikey',
'apisecret')
s.sendmail(msg['From'], msg['To'], msg.as_string())
s.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment