
Implementing software to replace legacy systems is always a challenge, especially when you're dealing with a system with as much legacy as
sendmail, which was first introduced as
delivermail in 1979.
refEach UNIX vendor, it seems, rewrote or heavily customized
sendmail. This has lead to sometimes conflicting implementations.
Case in point:
-tNormally, you invoke
sendmail(8) with a series of arguments indicating the subject of a message, the recipients, etc. When invoked this way, the command expects a message on standard input, waits for EOF, and then sends your message along.
However, sometimes you don't want to have to fiddle with command-line parameters; you've already written a perfectly fine message with headers.
-t is generally passed to
sendmail when you want to build a message envelope from an already-formatted message, with headers, etc. For example, if you had a file
foo.txt with a body like this:
From: Luke Faraone
To: John Smith
Subject: Hello, world!
Hi there.
you could send the message with a simple invocation of
cat foo.txt sendmail -t. The system would take care of ensuring a
Message-id was appended if appropriate, and queue the message to be sent. However, it is when you do slightly more complex invocations of
sendmail that things get ambiguous.
It turns out that implementations differ on what exactly it means when you use
-t in combination with naming destination addresses after the arguments to
sendmail.
exim4's documentation describes the situation in greater detail:
| extract_addresses_remove_ arguments | Use: main | Type: boolean | Default: true |
According to some Sendmail documentation (Sun, IRIX, HP-UX), if any addresses are present on the command line when the -t option is used to build an envelope from a message s To:, Cc: and Bcc: headers, the command line addresses are removed from the recipients list. This is also how Smail behaves. However, other Sendmail documentation (the O Reilly book) states that command line addresses are added to those obtained from the header lines. When extract_addresses_remove_arguments is true (the default), Exim subtracts argument headers. If it is set false, Exim adds rather than removes argument addresses.Thus, there's basically no mechanism for a program to know which behaviour to expect. God forbid two programs are installed on a system that expect different behaviours!
It appears that the default behaviour of Ruby is the opposite of what
exim4 (Debian's default mail client) expects. This has resulted in
numerous bug reports. Some replies suggest changing
exim4's defaults, while others advocate overriding ActionMailer and friends to use
sendmail -i instead, without
-t.
That said, its not really clear who's wrong here; at no point does there appear to have been a definitive specification for
sendmail, and as such we can hope for defined behaviour by common custom at best, and a sea of incompatibility bugs at worst. Amusingly,
POSIX standards have nothing to say on this subject of
sendmail at all; it
defines that a
mailx command must exist, but says that its sending mode may be implementation-specific.
As
Matthew Garrett writes, there's not enough gin in the world.