Rails 3 & Exim
At my company we usually host Rails projects on Debian. Exim has been
Debian's default MTA for quite some time so we stick with it. But
recently I've run into some troubles while upgrading a Rails 2
application to Rails 3.
With
ActionMailer.delivery_method = :sendmail
Rails
resorts to sendmail executable in its path to send emails. And while
Sendmail is quite happy with the default options (-i -t
)
used by Rails, the sendmail replacement provided by Exim isn't. Exim's
sendmail behaves differently with option -t
than
Sendmail. That's why I had to put the following
in config/environments/production.rb
file to make it
work.
ActionMailer::Base.sendmail_settings[:arguments] = '-i'
Before that I got the following error message via email
A message that you sent using the -t command line option contained no addresses that were not also on the command line, and were therefore suppressed. This left no recipient addresses, and so no delivery could be attempted.But as always
man exim
has all the nitty gritty details. Here is the fine print:
-t When Exim is receiving a locally-generated, non-SMTP message on its standard input, the -t option causes the recipients of the message to be obtained from the To:, Cc:, and Bcc: header lines in the message instead of from the command arguments. The addresses are extracted before any rewriting takes place and the Bcc: header line, if present, is then removed. If the command has any arguments, they specify addresses to which the message is not to be delivered. That is, the argument addresses are removed from the recipients list obtained from the headers. This is compatible with Smail 3 and in accordance with the documented behaviour of several versions of Sendmail, as described in man pages on a number of operating systems (e.g. Solaris 8, IRIX 6.5, HP-UX 11). However, some ver‐ sions of Sendmail add argument addresses to those obtained from the headers, and the O'Reilly Sendmail book documents it that way. Exim can be made to add argument addresses instead of subtracting them by setting the option extract_addresses_remove_arguments false. If there are any Resent- header lines in the message, Exim extracts recipients from all Resent-To:, Resent-Cc:, and Resent-Bcc: header lines instead of from To:, Cc:, and Bcc:. This is for compatibility with Sendmail and other MTAs. (Prior to release 4.20, Exim gave an error if -t was used in conjunction with Resent- header lines.) RFC 2822 talks about different sets of Resent- header lines (for when a message is resent several times). The RFC also specifies that they should be added at the front of the message, and separated by Received: lines. It is not at all clear how -t should operate in the present of multiple sets, nor indeed exactly what constitutes a "set". In practice, it seems that MUAs do not follow the RFC. The Resent- lines are often added at the end of the header, and if a message is resent more than once, it is com‐ mon for the original set of Resent- headers to be renamed as X-Resent- when a new set is added. This removes any possible ambiguity.