Created
September 15, 2010 21:16
-
-
Save jldupont/581501 to your computer and use it in GitHub Desktop.
Sending mail to local user
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
""" | |
Sending local email | |
Created on 2010-09-15 | |
@author: jldupont | |
""" | |
import smtplib | |
import getpass | |
SERVER = "localhost" | |
FROM = "somesender@localhost" | |
TO = ["%s@localhost" % getpass.getuser()] | |
SUBJECT = "Hello!" | |
TEXT = "This message was sent with Python's smtplib." | |
# Prepare actual message | |
message = """\ | |
From: %s | |
To: %s | |
Subject: %s | |
%s | |
""" % (FROM, ", ".join(TO), SUBJECT, TEXT) | |
# Send the mail | |
server = smtplib.SMTP(SERVER) | |
server.sendmail(FROM, TO, message) | |
server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment