A user has recently notified me that he cannot reply to my email messages because of white space in the address. He also mentioned the raw FROM field not being RFC 822 compliant - I don't know much about it and can't verify.
Here's the raw From field that he received:
From: SiteName someprefix@mg.somesite.io
This is the way I'm currently sending these emails:
msg_plain = render_to_string('email_template.txt', context)
msg_html = render_to_string('email_template.html', context)
EMAIL_FROM_FIELD = 'SiteName someprefix@mg.somesite.io'
mail_was_sent = send_mail(
email_subject,
msg_plain,
EMAIL_FROM_FIELD,
[profile.user.email],
html_message=msg_html,
)
What am I doing wrong?
You may define the form field as follow:
EMAIL_FROM_FIELD = 'SiteName <someprefix@mg.somesite.io>'