title: Detect bounced emails in Python smtplib
body: <p>I'm trying to catch all emails that bounced when sending them via smtplib in Python. I looked at this <a href="https://stackoverflow.com/questions/33545321/python-smtp-error-code-handling">similar post</a> which suggested adding an exception catcher, but I noticed that my <code>sendmail</code> function doesn't throw any exceptions even for fake email addresses.</p>
  
  <p>Here is my <code>send_email</code> function which uses <code>smtplib</code>. </p>
  
  <pre><code>def send_email(body, subject, recipients, sent_from="myEmail@server.com"):
      msg = MIMEText(body)
  
      msg['Subject'] = subject
      msg['From'] = sent_from
      msg['To'] = ", ".join(recipients)
  
      s = smtplib.SMTP('mySmtpServer:Port')
      try:
         s.sendmail(msg['From'], recipients, msg.as_string())
      except SMTPResponseException as e:
          error_code = e.smtp_code
          error_message = e.smtp_error
          print("error_code: {}, error_message: {}".format(error_code, error_message))
      s.quit()
  </code></pre>
  
  <p>Sample call:</p>
  
  <pre><code>send_email("Body-Test", "Subject-Test", ["fakejfdklsa@jfdlsaf.com"], "myemail@server.com")
  </code></pre>
  
  <p>Since I set the sender as myself, I am able to receive the email bounce report in my sender's inbox:</p>
  
  <pre><code>&lt;fakejfdklsa@jfdlsaf.com&gt;: Host or domain name not found. Name service error
      for name=jfdlsaf.com type=A: Host not found
  
  Final-Recipient: rfc822; fakejfdklsa@jfdlsaf.com
  Original-Recipient: rfc822;fakejfdklsa@jfdlsaf.com
  Action: failed
  Status: 5.4.4
  Diagnostic-Code: X-Postfix; Host or domain name not found. Name service error
      for name=jfdlsaf.com type=A: Host not found
  </code></pre>
  
  <p>Is there a way to get the bounce message through Python?</p>