473,327 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Plain text email?

Hi guys. I have a script that sends the info by email, but i'd like to
avoid the convertion to HTML by the email client or Gmail, because it
ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
be able to send SMTP mail and the receiver only get it in plain text.

Jul 19 '05 #1
11 4916
On 27 Jun 2005 15:38:59 -0700, Inkiniteo <ga****@gmail.com> wrote:
Hi guys. I have a script that sends the info by email, but i'd like to
avoid the convertion to HTML by the email client or Gmail, because it
ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
be able to send SMTP mail and the receiver only get it in plain text.


Can you give a short example of how you are building the email ?
Jul 19 '05 #2
On 27 Jun 2005 15:38:59 -0700, rumours say that "Inkiniteo"
<ga****@gmail.com> might have written:
Hi guys. I have a script that sends the info by email, but i'd like to
avoid the convertion to HTML by the email client or Gmail, because it
ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
be able to send SMTP mail and the receiver only get it in plain text.


Please tell us what you do more precisely:

* do you send the "info" as an attachment using the email package?
* do you create alternative text and HTML parts for the body?

I have never managed to send plain text email and receive it as HTML.
Perhaps you mean that some "smart" client does something stupid with
your text, eg. it removes line-breaks you have in your message?
Try this:

import smtplib

def send(server, from_whom, to_whom_list):
smtp = smtplib.SMTP(server)
smtp.sendmail(from_whom, to_whom_list,
"""From: %s
To: %s
Subject: test email

This is a test.
It has line breaks.
Does it come as three separate lines?""")

I tried it as

send('localhost', 't***@sil-tec.gr', ['t***@sil-tec.gr'])

and I had no problem. What happens for you (substitute other server and
email addresses, obviously :) ?
--
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
Jul 19 '05 #3
On 27 Jun 2005 15:38:59 -0700, rumours say that "Inkiniteo"
<ga****@gmail.com> might have written:
Hi guys. I have a script that sends the info by email, but i'd like to
avoid the convertion to HTML by the email client or Gmail, because it
ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
be able to send SMTP mail and the receiver only get it in plain text.


Please tell us what you do more precisely:

* do you send the "info" as an attachment using the email package?
* do you create alternative text and HTML parts for the body?

I have never managed to send plain text email and receive it as HTML.
Perhaps you mean that some "smart" client does something stupid with
your text, eg. it removes line-breaks you have in your message?
Try this:

import smtplib

def send(server, from_whom, to_whom_list):
smtp = smtplib.SMTP(server)
smtp.sendmail(from_whom, to_whom_list,
"""From: %s
To: %s
Subject: test email

This is a test.
It has line breaks.
Does it come as three separate lines?""" % (from_whom,
", ".join(to_whom_list))

I tried it as

send('localhost', 't***@sil-tec.gr', ['t***@sil-tec.gr'])

and I had no problem. What happens for you (substitute other server and
email addresses, obviously :) ?
--
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
Jul 19 '05 #4
Humm. I just create the message this way:

message = 'Serie:\t\t' + str(type) + str(series) + \
'\t\t\tUbicación:\t\t\t' + place + '\n' + \
'Date&Time:\t' + date

and send it with:
message = header + message
server = smtplib.SMTP('localhost')
server.sendmail('e****@email.com', email, message)
server.quit()

Jul 19 '05 #5
On 27 Jun 2005 16:09:38 -0700, rumours say that "Inkiniteo"
<ga****@gmail.com> might have written:
Humm. I just create the message this way: message = 'Serie:\t\t' + str(type) + str(series) + \
'\t\t\tUbicación:\t\t\t' + place + '\n' + \
'Date&Time:\t' + date and send it with:
message = header + message
server = smtplib.SMTP('localhost')
server.sendmail('e****@email.com', email, message)
server.quit()


And what goes wrong when you see the message? (BTW you don't have a
newline before "Ubicación:"; is it intentional?)

Tabs are infamous confusers of email clients, unfortunately.
--
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
Jul 19 '05 #6
Hi,

I had the exact opposite problem :-)

Hope this helps

Regards,

Philippe

#************************************************* *******************
def Mail(self,p_data): #data is string of text

you = wx.GetTextFromUser('EMAIL ADDRESS','ID')
if len(you) == 0:
return

self.__m_config = Config()

self.__m_config.Load()

me = self.__m_config.dict['ACCOUNT']
host = self.__m_config.dict['SMTP']
s = smtplib.SMTP()
s.connect(host)
s.login(me,self.__m_config.GPW())

the_text = p_data
msg = MIMEText(the_text)

# ***************GET RID OF THIS LINE TO HAVE PLAIN TEXT
************************************
msg.replace_header('Content-Type', 'text/html')
# ***************GET RID OF THIS LINE TO HAVE PLAIN TEXT
************************************
#msg.add_header('Content-Type', 'text/html')

msg['To'] = you
msg['Subject'] = self.__m_title
msg['From'] = self.__m_config.dict['FROM']
s.sendmail(me, [you], msg.as_string())
self.__m_list = []

Inkiniteo wrote:
Hi guys. I have a script that sends the info by email, but i'd like to
avoid the convertion to HTML by the email client or Gmail, because it
ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
be able to send SMTP mail and the receiver only get it in plain text.


Jul 19 '05 #7
"Inkiniteo" <ga****@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi guys. I have a script that sends the info by email, but i'd like to
avoid the convertion to HTML by the email client or Gmail, because it
ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
be able to send SMTP mail and the receiver only get it in plain text.
As long as your mimetype is text/plain you should have
minimal trouble. There's no way you can control what
the recipient's mail client does, however.

In particular, there are a lot of mail clients out there that
handle tabs poorly. Outlook Express is the poster child
for this: it ignores tabs completely, however it is by no
means the only culprit. It's simply the most widespread one.

In other words, use strings of spaces rather than tabs,
and you'll probably find your messages coming out
looking better.

John Roth


Jul 19 '05 #8
I see. So... what about sending HTML email? If i send HTML tagged text,
the client will be able to read it as HTML?

For example, if i send an email with: <header></header> <body>
<b>Yo!</></body> will the client read a bold Yo! ?

Because i can replace tabs with tables if this is possible.

Jul 19 '05 #9
On 27 Jun 2005 18:56:27 -0700,
"Inkiniteo" <ga****@gmail.com> wrote:
I see. So... what about sending HTML email? If i send HTML tagged
text, the client will be able to read it as HTML? For example, if i send an email with: <header></header> <body>
<b>Yo!</></body> will the client read a bold Yo! ?


That depends on the client.

IMO, HTML belongs on web pages, not in email. YMMV.

Regards,
Dan

--
Dan Sommers
<http://www.tombstonezero.net/dan/>
Jul 19 '05 #10
"Inkiniteo" <ga****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I see. So... what about sending HTML email? If i send HTML tagged text,
the client will be able to read it as HTML?

For example, if i send an email with: <header></header> <body>
<b>Yo!</></body> will the client read a bold Yo! ?

Because i can replace tabs with tables if this is possible.
To send HTML, you definitely need a mimetype. Otherwise
some clients will autodiagnose as HTML and attempt to render
it, some won't. Strictly speaking, they shouldn't do autodetection.

I also agree with Dan - HTML mail is evil, and I try to avoid it
whenever possible. That's one of the major vectors for worms,
viri and simliar malware.

John Roth


Jul 19 '05 #11
On 27 Jun 2005 18:56:27 -0700, rumours say that "Inkiniteo"
<ga****@gmail.com> might have written:
I see. So... what about sending HTML email? If i send HTML tagged text,
the client will be able to read it as HTML?


I agree with the others that HTML is part of the web, not of the e-mail
system.

I suggest you send your "info" as an attached text file; no client will
mess with it. The email package is your friend for MIME messages.
--
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
Jul 19 '05 #12

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

Similar topics

10
by: J. Alan Rueckgauer | last post by:
Hello. I'm looking for a simple way to do the following: We have a database that serves-up content to a website. Some of those items are events, some are news articles. They're stored in the...
14
by: Akseli Mäki | last post by:
Hi, Hopefully this is not too much offtopic. I'm working on a FAQ. I want to make two versions of it, plain text and HTML. I'm looking for a tool that will make a plain text doc out of the...
8
by: LRW | last post by:
I'm not sure this message is totally appropriate for this group, so please, if anyone has a better group suggestion, let me know! My company sends out a monthly newsletter in HTML format to our...
2
by: gRizwan | last post by:
Hello all. can any one tell how can we receive POST data in a ASP form with enctype="text/plain" ? thanks. Riz
2
by: Peter Nilsson | last post by:
In a post regarding toupper(), Richard Heathfield once asked me to think about what the conversion of a char to unsigned char would mean, and whether it was sensible to actually do so. And pete has...
7
by: toby989 | last post by:
Hi All Sorry for reposting...the entries of the post from 11/23/2005 by Eric Lindsay have been removed from the server already and I am seeing only the header. So, I have the problem of...
6
by: monomaniac21 | last post by:
hi all how can u send a plain text version of an email with the html so that the users mail client can access this plain text version? kind regards marc
0
by: Rey | last post by:
Howdy all. Am using visual web developer 2005 (vb), xp pro sp2. In testing of the system.net.mail to send email from an aspx page where I'm pulling the email contents from a textbox, find that...
0
by: lundmark | last post by:
When I send a plain-text message using Outook 2007, I want hard line breaks to be added to my outgoing message. I cannot seem to make this happen. I have configured Outlook to Automatically wrap...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.