472,374 Members | 1,319 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 software developers and data experts.

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

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'] = 'a*@xx.net'
msg['To'] = 'a*@xx.net'
msg['Subject'] = 'test subject'

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

server = smtplib.SMTP('mail.xx.net')
server.sendmail('a*@xx.net', 'a*@xx.net', msg.as_string())
server.quit()
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++

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 :
+++++++++++++++++++++++++++++++++++++++++++
Hello,
1,
2,
ok
+++++++++++++++++++++++++++++++++++++++++++

I would like to get help from you, thanks so much.
Jun 27 '08 #1
3 10411
perhaps change html

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

to plain

body=MIMEText('hello,\r\n
ok',_subtype='plain',_charset='windows-1255')
Jun 27 '08 #2
Lie
On Jun 19, 4:02*pm, Justin Ezequiel <justin.mailingli...@gmail.com>
wrote:
perhaps change html

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

to plain

body=MIMEText('hello,\r\n
ok',_subtype='plain',_charset='windows-1255')
If that was the case, and you needed a line break in html-mode, use
<br /or <ptags.
Jun 27 '08 #3
On Jun 19, 6:12 pm, Lie <Lie.1...@gmail.comwrote:
On Jun 19, 4:02 pm, Justin Ezequiel <justin.mailingli...@gmail.com>
wrote:
perhaps change html
body=MIMEText('hello,\r\n
ok',_subtype='html',_charset='windows-1255')
to plain
body=MIMEText('hello,\r\n
ok',_subtype='plain',_charset='windows-1255')

If that was the case, and you needed a line break in html-mode, use
<br /or <ptags.

Thanks all,
and yes, if I use "plain" or use HTML tag "<br>", it worked:
(1) HTML:
I use tag "<br />" and "&nbsp;", and when I reply that mail, I will
see "<br>" tag in mail content, it is not a good option.
thanks,
Evan
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

53
by: Oliver Fromme | last post by:
Hi, I'm trying to write a Python function that parses an expression and builds a function tree from it (recursively). During parsing, lambda functions for the the terms and sub-expressions...
2
by: ae | last post by:
what is the signficance of the @?
4
by: Kerem Gümrükcü | last post by:
Hi, i am about to burst!!! how can i make my string break inside a textbox? i mean with a control charater like "\n", but it does not work! i have a string and i must set the wrap manuall, not...
3
by: Chris Mahoney | last post by:
Hi I have two machines, one running Win 2000 and VS.NET 2002, and one running Mac OS 10.2. I can develop web apps on my Windows machine, and look at them in IE, and they look fine. But if I...
11
by: Sven | last post by:
I want this: when I press commandbutton1, then the program should send the keystroke "enter" to text1.text... how can I do this?
2
by: SAL | last post by:
I have the following line of code in my Page_Load Event of my ASP.net page: txtExplanationofChange.Attributes.Add ("style","overflow :hidden"); which allows me to can turn off the Scrollbar of my...
3
by: Frank | last post by:
I am attempting to develop a solution where I handle bounced e-mails. I wish to field all bounced emails in a custom email account such a bounced@mycompany.com From the aricle at...
71
by: Jack | last post by:
I understand that the standard Python distribution is considered the C-Python. Howerver, the current C-Python is really a combination of C and Python implementation. There are about 2000 Python...
6
by: Russ P. | last post by:
I've always appreciated Python's lack of requirement for a semi-colon at the end of each line. I also appreciate its rules for automatic line continuation. If a statement ends with a "+", for...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.