Bug 1269770 - dnf-automatic generates broken emails
dnf-automatic generates broken emails
Product: Fedora
Classification: Fedora
Component: dnf (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: rpm-software-management
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2015-10-08 03:57 EDT by Olivier Andrieu
Modified: 2016-07-19 14:08 EDT (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-07-19 14:08:44 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Olivier Andrieu 2015-10-08 03:57:01 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") % (
Comment 1 Jaroslav Mracek 2015-10-13 10:30:46 EDT
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
Comment 2 Olivier Andrieu 2015-10-26 09:15:57 EDT
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
Comment 3 Fedora Admin XMLRPC Client 2016-07-08 05:28:24 EDT
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 4 Fedora End Of Life 2016-07-19 14:08:44 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.