from_email = None
for header in headers.split('\n'):
(field, value) = header.split(':')
- headers_dict[field] = value
if (field == 'From'):
from_email = value
+ elif (field == 'Subject'):
+ subject = value
+ else:
+ # Don't put From and Subject in the dict, else they'll be
+ # present twice.
+ headers_dict[field] = value
msg = EmailMessage(
# Only setting the From address through headers won't set the
# envelope address right.
from_email = from_email,
+ subject = subject,
body = body,
to = addresses,
headers = headers_dict