Skip to content

Instantly share code, notes, and snippets.

@guysoft
Created August 7, 2014 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guysoft/a14cc88b9b9afd5fc452 to your computer and use it in GitHub Desktop.
Save guysoft/a14cc88b9b9afd5fc452 to your computer and use it in GitHub Desktop.
send email
#!/usr/bin/python
import smtplib
import sys
import string
fromaddr = '<your gmail address>'
toaddrs = '<destination address>'
msg = sys.argv[1]
subject = "3D printer message"
body = string.join((
"From: %s" % fromaddr,
"To: %s" % toaddrs,
"Subject: %s" % subject,
"",
msg), "\r\n")
# Credentials (if needed)
username = '<username>'
password = '<password>'
# The actual mail send
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username,password)
server.sendmail(fromaddr, toaddrs, body)
server.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment