Rails & sendmail recipients with -t option not sup

2019-08-07 03:29发布

问题:

I have a development environment file that contains the following

config.action_mailer.delivery_method = :sendmail
config.action_mailer.sendmail_settings = {:arguments => '-i'}

I'm logging into the rails console with that environment loaded up

class MyMailer < ActionMailer::Base
  def test_email
    mail(:to => 'somebodyelse@somewhere.com', 
         :subject => 'test', 
         :from => 'somebody@somewhere.com')
  end
end

MyMailer::test_email.deliver

And instead of getting that email delivered, I get this

sendmail: recipients with -t option not supported

Sendmail is actually not installed on this machine, instead, I've configured SSMTP, following the instructions at http://www.igvita.com/2007/08/29/ssmtp-relay-mail-delivery-in-rails/

I get the same error when I'm sending by :smtp. So it looks to me like either my test is not using the same environment variable or Rails simply ignore the configuration.

回答1:

The environmental loader was being overwritten with other values from /initializers/setup_mail.rb, so ActionMailer::Base would end up using the wrong protocol.