Skip to content

Instantly share code, notes, and snippets.

@berkerpeksag
Last active June 12, 2016 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berkerpeksag/d7a87a6cda9375e93a5c71f53cece854 to your computer and use it in GitHub Desktop.
Save berkerpeksag/d7a87a6cda9375e93a5c71f53cece854 to your computer and use it in GitHub Desktop.
import email
import email.policy
from email.mime.multipart import MIMEMultipart
m = email.message_from_string('', policy=email.policy.default)
m['To'] = 'a@b.com'
m['To'] = 'a@b.com' # will raise ValueError
# and here is an alternative way
m = MIMEMultipart()
m.policy = email.policy.default
m['To'] = 'a@b.com'
m['To'] = 'a@b.com' # will raise ValueError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment