classification
Title: [mimetext] long lines get cut with exclamation mark and newline
Type: behavior Stage: resolved
Components: Versions: Python 2.5
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: Dmitry.Simonov, Jeff.Hull, amaury.forgeotdarc, martijntje, r.david.murray
Priority: normal Keywords:

Created on 2009-06-23 14:33 by martijntje, last changed 2011-09-06 12:56 by Dmitry.Simonov. This issue is now closed.

Messages (6)
msg89627 - (view) Author: Martijn Otto (martijntje) Date: 2009-06-23 14:33
When using mimetext, long lines are cut at character 990, at which place
an exclamation mark, a newline and a space are inserted. After this the
line continues... For example, this line:

000000000148                                                           
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       
                                   0220090622N0   K.        de       
Boer                                                                     
                                                                  
Badhuisstraat                      36                                       
         2012 CPHAARLEM                            NED20090622       
1500     628215290           19030201keesdeboerisdebeste@hotmail.com     
              0123456789  

will get changed to

000000000148                                                           
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       
                               0220090622N0   K.        de        Boer 
                                                                       
                                                             
Badhuisstraat                      36                                  
             2012 CPHAARLEM                            NED20090622     
  1500     628215290           19030201keesdeboerisdebeste@hotm!
 ail.com                   0123456789
msg89668 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-06-24 16:38
Are you referring to the email.mime.text.MIMEText class (or
email.MIMEText.MIMEText)?

How did you use it? A basic test (print MIMEText('long'*500)) did not
show any line break.
msg97461 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-01-09 17:06
Since there's no response I'm closing this as 'works for me'.
msg121361 - (view) Author: Jeff Hull (Jeff.Hull) Date: 2010-11-17 15:32
I also have this problem with text getting replaced with the exclamation point.

I am using this class.
from email.MIMEText import MIMEText

Perhaps it didn't work for you because you didn't send it via email. 

try this code

	msgAlternative = MIMEMultipart('alternative')
	msgText = MIMEText(text, 'html')
	msgAlternative.attach(msgText)
	msg.attach(msgAlternative)	

	mailServer = smtplib.SMTP()
	mailServer.connect(serverURL)
	mailServer.login(user, pass)
	mailServer.sendmail(sender,to, msg.as_string())
	mailServer.quit()
msg121363 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-11-17 16:18
Perhaps.

You can help narrow this down by doing the following:  In your program do a 'print msg.as_string()' and see if you see the ! problem there.

If not, try using several different SMTP servers to send your email.  If the ! problem shows up with all of them, then perhaps the problem is with smtplib.  In that case, please post a full working program including all needed input data so that I can test it myself against my own mail server.

Also please confirm that the problem still exists if you use 2.7, since that is the only 2.x release that gets bug fixes at this time.
msg143601 - (view) Author: Dmitry Simonov (Dmitry.Simonov) Date: 2011-09-06 12:56
Quote:
==================
Notes

Note that mailservers have a 990-character limit on each line contained within an email message. If an email message is sent that contains lines longer than 990-characters, those lines will be subdivided by additional line ending characters, which can cause corruption in the email message, particularly for HTML content. To prevent this from occurring, add your own line-ending characters at appropriate locations within the email message to ensure that no lines are longer than 990 characters.
==================
History
Date User Action Args
2011-09-06 12:56:30Dmitry.Simonovsetnosy: + Dmitry.Simonov
messages: + msg143601
2010-11-17 16:18:25r.david.murraysetmessages: + msg121363
2010-11-17 15:32:03Jeff.Hullsetnosy: + Jeff.Hull
messages: + msg121361
2010-08-04 03:07:11terry.reedysetstatus: open -> closed
2010-01-09 17:06:49r.david.murraysetpriority: normal

nosy: + r.david.murray
messages: + msg97461

resolution: works for me
stage: resolved
2009-06-24 16:38:56amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg89668
2009-06-23 14:33:06martijntjecreate