Red Hat Bugzilla – Bug 1269770
dnf-automatic generates broken emails
Last modified: 2016-07-19 14:08:44 EDT
Description of problem:
The emails sent by dnf-automatic arrive mangled: some headers are shown as part of the message body.
Version-Release number of selected component (if applicable):
This patch fixes it for me:
--- /usr/lib/python2.7/site-packages/dnf/automatic/emitter.py~ 2015-09-22 13:57:12.000000000 +0200
+++ /usr/lib/python2.7/site-packages/dnf/automatic/emitter.py 2015-10-08 09:39:46.199555624 +0200
@@ -97,7 +97,7 @@
# Send the email
smtp = smtplib.SMTP(self._conf.email_host)
- smtp.sendmail(email_from, email_to, str(message))
+ smtp.sendmail(email_from, email_to, message.as_string())
except smtplib.SMTPException as exc:
msg = _("Failed to send an email via '%s': %s") % (
Please could you provide additional information about a problem (headers and body before and after patch) and how we can reproduce it.
Also please make a pull request with your fix to dnf project on https://github.com/rpm-software-management/dnf
pull request: https://github.com/rpm-software-management/dnf/pull/373
You can see from python's documentation what's wrong: str() on a message is equivalent to as_string(unixfrom=True) (the default for unixfrom is False). unixfrom makes an envelope header out of the From: header of the message. cf as_string documentation: https://docs.python.org/2/library/email.message.html#email.message.Message.as_string
But that's redundant with sendmail(), which creates an envelope header out of its from_addr argument: https://docs.python.org/2/library/smtplib.html#smtplib.SMTP.sendmail
Note that the examples for the email package all use as_string(), not str(): https://docs.python.org/2/library/email-examples.html
This package has changed ownership in the Fedora Package Database. Reassigning to the new owner of this component.
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.
If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
Thank you for reporting this bug and we are sorry it could not be fixed.