From d62baca1c5b1f9eb0078bc623f4fc8e2f26084e0 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 17 Jul 2014 13:04:10 -0700 Subject: [PATCH] email: Split sender into both sendmail's -F and -f Use -F for the name and -f for the address, instead of passing the composite "name
" to -f. Only the address is used in the SMTP envelope [1,2], so most mailers will probably ignore -F. For example, Postfix only uses it when there is no 'From' header in the message itself [3]. The old behavior broke some sendmail implementation that assumed the whole -f argument was an address. I haven't noticed one of these sendmail implementions myself, but they'll create envelope senders like: MAIL FROM:<"foobar " > when we only want: MAIL FROM: [1]: http://tools.ietf.org/html/rfc2821#section-3.3 [2]: http://tools.ietf.org/html/rfc2821#section-4.1.1.2 [3]: http://www.postfix.org/sendmail.1.html --- rss2email/email.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rss2email/email.py b/rss2email/email.py index bee9e03..9972607 100644 --- a/rss2email/email.py +++ b/rss2email/email.py @@ -324,11 +324,12 @@ def sendmail_send(sender, recipient, message, config=None, section='DEFAULT'): config = _config.CONFIG message_bytes = _flatten(message) sendmail = config.get(section, 'sendmail') + sender_name,sender_addr = _parseaddr(sender) _LOG.debug( 'sending message to {} via {}'.format(recipient, sendmail)) try: p = _subprocess.Popen( - [sendmail, '-f', sender, recipient], + [sendmail, '-F', sender_name, '-f', sender_addr, recipient], stdin=_subprocess.PIPE, stdout=_subprocess.PIPE, stderr=_subprocess.PIPE) stdout,stderr = p.communicate(message_bytes) -- 2.26.2