Bug 1269770 - dnf-automatic generates broken emails
Summary: dnf-automatic generates broken emails
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 22
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: rpm-software-management
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2015-10-08 07:57 UTC by Olivier Andrieu
Modified: 2016-07-19 18:08 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2016-07-19 18:08:44 UTC
Type: Bug

Attachments (Terms of Use)

Description Olivier Andrieu 2015-10-08 07:57:01 UTC
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 14:30:46 UTC
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 13:15:57 UTC
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 09:28:24 UTC
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 18:08:44 UTC
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.