Note that there are some explanatory texts on larger screens.

plurals
  1. POpython smtplib using gmail: messages with a body longer than about 35 characters are never received
    primarykey
    data
    text
    <p>I have the strangest bug. I am using smtplib to send email from a gmail account. Every time that I run the script I see the message show up in the "sent" tab of the gmail account that I am using to send. However sometimes don't get the message on the receiving end. </p> <p>I have noticed a correlation between the length of the body of the message and whether I receive it. A message of "foo" gets through every time and my desired message, which is about 200 characters long never does. I tried sending messages with body lengths between zero and 60. Both times I tried this all 60 show up in the 'sent' folder of the sending gmail account, but only the following show up in the receiving email account:</p> <p><img src="https://i.stack.imgur.com/ib8zq.png" alt="enter image description here"></p> <p>Here is the code I use to send the messages:</p> <pre><code> for i in range(100): mail('someaddress@gmail.com','testing limit',str(i) + "a"*i) </code></pre> <p>And here is the mail function:</p> <pre><code>def mail(to, subject, text, attach=None): """Sends an email, formatted as HTML to list of senders with an optional attachment. Specifically, the 'to' argument must be a comma seperated list of email addresses. 'subject' and 'text' are what appear in the email subject and body, respectively and 'attach' is a path to an attachment. """ msg = MIMEMultipart() # build the email header msg['From'] = 'A Concerned Robot' msg['To'] = to msg['Subject'] = subject # attach our body text as html msg.attach(MIMEText(text,'html')) # attach the attachment if its there part = MIMEBase('application', 'octet-stream') if attach is not None: part.set_payload(open(attach, 'rb').read()) Encoders.encode_base64(part) part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(attach)) msg.attach(part) # open up a line with the server mailServer = smtplib.SMTP("smtp.gmail.com", 587) mailServer.ehlo() mailServer.starttls() mailServer.ehlo() # login, send email, logout mailServer.login(conf.user, conf.pw) mailServer.sendmail(conf.user, to, msg.as_string()) mailServer.close() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload