#23063: send email 1.6.5 OK, 1.7c1 malformed packet in wireshark
-------------------------------------+-------------------------------------
Reporter: contact@… | Owner: nobody
Type: Bug | Status: new
Component: Core (Mail) | Version: 1.7
Severity: Normal | Resolution:
Keywords: send_mail, smtp, | Triage Stage: Accepted
malformed, packet | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Comment (by ainslied):
Sure, here is the code :
{{{
import smtplib
from email.mime.text import MIMEText
msg = MIMEText('Body goes here')
msg['Subject'] = 'Hello'
msg['From'] = 'webmaster@xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
msg['To'] = '[email protected]'
s = smtplib.SMTP('SSL0.OVH.NET', 587, timeout = 4000)
s.login('webmaster@xxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'xxxxxxxx')
s.sendmail('webmaster@xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
['[email protected]'], msg.as_string())
s.quit()
}}}
It seems, I could not use as_string() nor as_byte() as shown in this
[https://docs.python.org/3.4/library/email-examples.html#email-examples
official exemple] :
{{{
import smtplib
from email.mime.text import MIMEText
fp = open(textfile, 'rb')
msg = MIMEText(fp.read())
fp.close()
msg['Subject'] = 'The contents of %s' % textfile
msg['From'] = me
msg['To'] = you
s = smtplib.SMTP('localhost')
s.send_message(msg)
s.quit()
}}}
-> Anyway the
[https://docs.python.org/3.4/library/smtplib.html#smtplib.SMTP.sendmail
SMTP.sendmail] part of the doc seems to be the most important to explain
our issue :
{{{
SMTP.sendmail(from_addr, to_addrs, msg, ...)
The required arguments are ..., and a message string.
msg may be a string containing characters in the ASCII range, or a byte
string.
A string is encoded to bytes using the ascii codec, and lone \r and \n
characters are converted to \r\n characters.
A byte string is not modified.
}}}
-> '''A byte string is not modified.'''
That seems to expain why it works with python and not with the Django
code.
So it seems to be not because of the policy but because of the "byte
string" transmitted to the sendmail function.
--
Ticket URL: <https://code.djangoproject.com/ticket/23063#comment:31>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/077.5b31c275d389b1e2fb83b5a2a0649051%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.