Skip to content

Instantly share code, notes, and snippets.

@cstrap
Created March 17, 2015 15:34
Show Gist options
  • Save cstrap/b4541c78c806e8d8ad1a to your computer and use it in GitHub Desktop.
Save cstrap/b4541c78c806e8d8ad1a to your computer and use it in GitHub Desktop.
Integrate mailtrap.io - plain python
import smtplib
from email.mime.text import MIMEText
msg = MIMEText('There was a terrible error that occured and I wanted you to know!')
msg['Subject'] = 'Hello world'
msg['From'] = 'from@example.com'
msg['To'] = 'to@example.com'
username = 'mailtrap.io username'
password = 'mailtrap.io password'
# The actual mail send
server = smtplib.SMTP('mailtrap.io', 2525)
server.starttls()
server.login(username,password)
server.sendmail('from@example.com', ['to@example.com'], msg.as_string())
server.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment