Created
January 30, 2014 15:07
-
-
Save calston/8710552 to your computer and use it in GitHub Desktop.
Send an email
This file contains 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/python | |
import sys, os, time | |
import smtplib | |
from email.MIMEText import MIMEText | |
from email.MIMEMultipart import MIMEMultipart | |
from email.MIMEImage import MIMEImage | |
def mailThings(subject, content, to): | |
struct = """<html> | |
<head></head> | |
<body style="font-family:arial,sans-serif;"> | |
%s | |
</body> | |
</html>""" % content | |
me = 'whatever <whoever@wherever>' | |
cont = MIMEText(struct, 'html') | |
msg = MIMEMultipart('related') | |
msg['Subject'] = subject | |
msg['From'] = me | |
msg['To'] = ', '.join(to) | |
msg.attach(cont) | |
s = smtplib.SMTP() | |
s.connect() | |
s.sendmail(me, you, msg.as_string()) | |
s.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment