Skip to content

Commit

Permalink
No policy in Python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Mortal committed May 1, 2015
1 parent 39c1ef6 commit c896ece
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions emailtunnel/send.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import six
import sys
import argparse
import smtplib
Expand Down Expand Up @@ -97,9 +98,13 @@ def main(*args, **kwargs):
message.set_body_text(body, args.encoding)

from email.generator import Generator
policy = email.message.compat32
g = Generator(
sys.stdout, maxheaderlen=80, policy=policy, mangle_from_=False)
if six.PY3:
policy = email.message.compat32
g = Generator(
sys.stdout, maxheaderlen=80, policy=policy, mangle_from_=False)
else:
g = Generator(
sys.stdout, maxheaderlen=80, mangle_from_=False)
try:
g.flatten(message.message, unixfrom=False)
except:
Expand Down

0 comments on commit c896ece

Please sign in to comment.