Reputation: 2397
Good afternoon,
I'm facing a problem about the way to send email through my application hosted on hostingrails.
In my config/initializers I added a file "setup_mailer" containing this
ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.default_charset = "utf-8"
# Production
if Rails.env.production?
ActionMailer::Base.sendmail_settings = {
:location => '/usr/sbin/sendmail',
:arguments => '-i -t -f [email protected]'
}
end
and my mailer is as below
class Notification < ActionMailer::Base
def subscription_confirmation(user)
setup_email(user)
mail(:to => @recipients, :subject => "blabla")
end
protected
def setup_email(user)
@recipients = user.email
@from = "[email protected]"
headers "Reply-to" => "[email protected]"
@sent_on = Time.now
@content_type = "text/html"
end
end
It seems to work very fine on my local machine. But in production, emails are not sent properly and I receive this message in my support inbox.
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.
If you have any idea, the support seems cannot help me, hope some of you'll have ideas or config files from hostingrails to share.
Thank you, albandiguer
Upvotes: 1
Views: 1378
Reputation: 46
I had exactly the same problem - resolved it by removing the -t from the sendmail_settings.
I haven't looked much further to investigate other implications, but at least it works. But from the man page:
-t Extract recipients from message headers. These are added to any
recipients specified on the command line.
With Postfix versions prior to 2.1, this option requires that no
recipient addresses are specified on the command line.
So maybe just a difference in Postfix versions?
Upvotes: 3
Reputation: 9752
Try calling to_s on user.email or specifying user email as "#{user.email}"
Upvotes: 0