[SMTPLIB] how to send a "Multiline" mail with smtplib?

Evan xdicry at gmail.com
Thu Jun 19 09:57:18 CEST 2008

Hello -

I'm new with Python, I try to do a mail problem, the code likes below:


import smtplib
import mimetypes
from email.Encoders import encode_base64
from email.MIMEAudio import MIMEAudio
from email.MIMEBase import MIMEBase
from email.MIMEImage import MIMEImage
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText

msg = MIMEMultipart()
msg['From'] = 'ab at xx.net'
msg['To'] = 'ab at xx.net'
msg['Subject'] = 'test subject'

body=MIMEText('hello,\r\n ok',_subtype='html',_charset='windows-1255')

server = smtplib.SMTP('mail.xx.net')
server.sendmail('ab at xx.net', 'ab at xx.net', msg.as_string())


I try to use "\r\n" or "\n", but no luck, nothing with them, I still
get a Single-line text in the mail.
hello, ok

So how do I send a multiline mail? such as :

I would like to get help from you, thanks so much.

More information about the Python-list mailing list