Created
December 11, 2012 20:44
-
-
Save trungtran/4261975 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import os | |
from email.mime.text import MIMEText | |
from email.MIMEMultipart import MIMEMultipart | |
from email.MIMEBase import MIMEBase | |
from email import Encoders | |
msg = MIMEMultipart() | |
msg['Subject'] = "A subject" | |
msg['From'] = "[email protected]" | |
msg['To'] = "[email protected]" | |
# Attach Message | |
msg.attach(MIMEText("Test body")) | |
# Send the message | |
sendmail = os.popen('sendmail [email protected]', 'w') | |
sendmail.write(msg.as_string()) | |
# Print sucess/failure | |
if sendmail.close() is not None: | |
print 'Error sending mail'; | |
else: | |
print 'Sent mail successfully' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment