[Tutor] need help with sending email

Christopher Arndt chris.arndt at web.de
Fri Jan 5 20:11:11 CET 2007


shawn bright schrieb:
> lo there all.
> 
> i am in a tight spot because i need to send an email that it mime
> encoded plain-text ( not html or anything )
> 
> anyone know of a good tutorial or recipe out there ?

Simplified example from http://www.python.org/doc/current/lib/node162.html:

# Import the email modules we'll need
from email.MIMEText import MIMEText

# Create a text/plain message
msg = MIMEText("Hello World!")

# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = 'This is a test message'
msg['From'] = 'me'
msg['To'] = 'you'

# Print string repreentation of message
print msg.as_string()


Outputs:

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: This is a test message
From: me
To: you

Hello World!


More information about the Tutor mailing list