0

I know this issue is there a thousand times. But mine seems strange :-)

I am using heroku. I wanna mail via SMTP. What are my correct settings for sending emails?

Please keep in mind, that my MailService is something like "gmail" or "gmx" and not my host superapp.herokuapp.com

my application.rb:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
    from: ENV['MAIL_SENDER_EMAIL_ADDRESS'],
    address: ENV['MAIL_SENDER_SERVER_HOST'],
    authentication: :login,
    enable_starttls_auto: ENV['MAIL_SENDER_TLS'],
    user_name: ENV['MAIL_SENDER_USERNAME'],
    password: ENV['MAIL_SENDER_PASSWORD']}
config.action_mailer.default = {
    :charset => "utf-8",
    from: ENV['MAIL_SENDER_EMAIL']}
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_deliveries = true

in my production.rb

config.action_mailer.default_url_options = {host: ENV['RAILS_HOST']}
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_deliveries = true

What is the right config to get rid of that error?

ActionView::Template::Error (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true)

ENV['RAILS_HOST'] = "superapp.herokuapp.com" does not work

Jan
  • 12,992
  • 9
  • 53
  • 89

1 Answers1

0

Loading it as an ENV variable caused it to throw the error for me and confused me for the past few hours.

In the end I added the following with the correct value to each environment file:

test.rb / development.rb / production.rb

Devise 3.2.x

Rails 4.1.x

Thanks to maudulus

# Default Mailer Host
  Rails.application.routes.default_url_options[:host] = 'domain.com'
Community
  • 1
  • 1
blnc
  • 4,384
  • 1
  • 28
  • 42