fork download
  1. #!/usr/bin/env python3
  2. import email.policy
  3.  
  4. msg = email.message_from_string("""From test-sender@example.com
  5. From: test-sender@example.com
  6. To: test-recipient@example.com
  7. Subject: test simple message
  8.  
  9. It's a test.
  10.  
  11. -- Best regards.""", policy=email.policy.default)
  12.  
  13. msg.set_content("Заменили текст.")
  14.  
  15. print(msg)
  16.  
  17.  
Success #stdin #stdout 0.09s 14240KB
stdin
Standard input is empty
stdout
From: test-sender@example.com
To: test-recipient@example.com
Subject: test simple message
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
MIME-Version: 1.0

0JfQsNC80LXQvdC40LvQuCDRgtC10LrRgdGCLgo=