473,574 Members | 2,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[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.MIMEMulti part 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='h tml',_charset=' windows-1255')
msg.attach(body )

server = smtplib.SMTP('m ail.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 10619
perhaps change html

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

to plain

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

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

to plain

body=MIMEText(' hello,\r\n
ok',_subtype='p lain',_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.mailing li...@gmail.com >
wrote:
perhaps change html
body=MIMEText(' hello,\r\n
ok',_subtype='h tml',_charset=' windows-1255')
to plain
body=MIMEText(' hello,\r\n
ok',_subtype='p lain',_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
3633
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 are constructed on the fly. Now my problem is lazy evaluation. Or at least I think it is. :-)
2
1395
by: ae | last post by:
what is the signficance of the @?
4
4103
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 controled by the wordwrap property of the textbox. as i alread said: "\n" does not work! Language s C#
3
2246
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 try to view my pages in Safari (Apple's web browser) on my Mac, there are various formatting problems. I've investigated what's happening and it...
11
3205
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
5148
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 multiline textbox. I am still fairly new to developing in ASP.net and C#, and I'm not sure if there is a better way to disable the scrollbar. The...
3
5403
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 http://www.systemwebmail.com/faq/2.7.aspx, I gather I could use: mail.Headers.Add( "Reply-To", "alternate_email@mycompany.com" ); When I test this from a test...
71
3259
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 files included in the Windows version of Python distribution. I'm not sure how much of the C-Python is implemented in C but I think the more modules...
6
1974
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 example, Python recognizes that the statement obviously must continue. I've noticed, however, that the same rule does not apply when a line ends with...
0
7736
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8067
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8107
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3748
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3756
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2252
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1352
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1071
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.