Use -F for the name and -f for the address, instead of passing the
composite "name <address>" 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 (reportedly OpenSMTPD). I haven't
noticed one of these sendmail implementions myself, but they'll create
envelope senders like:
MAIL FROM:<"foobar <abc>" <foo@bar>>
when we only want:
MAIL FROM:<foo@bar>
[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
Signed-off-by: W. Trevor King <wking@tremily.us>
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)