title: How do you prevent smtplib library from sending no subject?
body: <pre><code>for i in range(3):
      gmail_user = 'email'
      gmail_password = 'pass'
      
      sent_from = gmail_user
      to = ['email']
      subject = 'Lorem ipsum dolor sit amet'
      body = rand_quote
      
      email_text = (&quot;&quot;&quot;\
      From: %s
      To: %s
      Subject: %s
      
      %s
      &quot;&quot;&quot; % (sent_from, &quot;, &quot;.join(to), subject, body))
      
      try:
          smtp_server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
          smtp_server.ehlo()
          smtp_server.login(gmail_user, gmail_password)
          smtp_server.sendmail(sent_from, to, email_text)
          smtp_server.close()
          print (&quot;Email sent successfully!&quot;)
      except Exception as ex:
          print (&quot;Something went wrong….&quot;,ex)
  </code></pre>
  <p>When I remove the for loop the code runs great with the subject and body sending properly however when I try to run something like the code above the email comes is sent <a href="https://i.stack.imgur.com/cZclH.png" rel="nofollow noreferrer">as such.</a></p>