Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 0.94 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. modifying multipart headers when using the email library in python
  2. from email.mime.text import MIMEText
  3.        
  4. from email.mime.multipart import MIMEMultiPart
  5.  
  6. msg = MIMEMultipart('alternative')
  7. text = 'add this text to the multipart'
  8. textMIME = MIMEText(text, 'plain')
  9. msg.attach(MIMEText)
  10.  
  11. text2 = 'add this text to the next multipart'
  12. text2MIME = MIMEText(text2, 'plain')
  13. msg.attach(MIME2Text)
  14.        
  15. Return-Path: xxxxx
  16. X-Original-To: xxxxxxxxx
  17. Delivered-To: xxxxxxx
  18. Received: from xxxxxx
  19.         to xxxxxxxxx
  20.         for xxxxxxxxx
  21. Content-Type: multipart/alternative;
  22.  boundary="==========yyyyyyyy=="
  23. MIME-Version: 1.0
  24. Message-Id: xxxxxxx
  25. Date: xxxxxx
  26. From: xxxxx
  27. To: xxxxx
  28.  
  29. --==========yyyyyyyy==
  30. Content-Type: xxxxxxx
  31. MIME-Version: 1.0
  32. Content-Transfer-Encoding: 7bit
  33.  
  34. add this text to the multipart
  35.  
  36. --==========yyyyyyyy==
  37. Content-Type: xxxxxxx
  38. MIME-Version: 1.0
  39. Content-Transfer-Encoding: 7bit
  40.  
  41. add this text to the next multipart
  42. --==========yyyyyyyy==