473,651 Members | 2,531 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 10634
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
3664
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
1398
by: ae | last post by:
what is the signficance of the @?
4
4106
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
2248
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 seems that ASP.NET is discriminating against Safari (and other browsers).
11
3206
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
5155
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 code above turns off the scrollbar just fine, however the textbox does not remain in the location...
3
5406
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 web app, I don't seem to field a bounced email
71
3282
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 implemented in C, the better performance and lower memory footprint it will get. I wonder if it's...
6
1976
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 "and," "or," or "not." Yes, it's a minor point, but shouldn't the same rule apply? Seems like it...
0
8347
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8275
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8792
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7294
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6157
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4143
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4280
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1905
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1585
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.