Example of mail gun using SMTP with a rails application

Home   »   Example of mail gun using SMTP with a rails application

```
# production.rb
# mail gun
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.smtp_settings = { address: "smtp.mailgun.org",
                                         port: 587,
                                         user_name: Chamber.dig!(:smtp_email, :mail_username),
                                         password: Chamber.dig!(:smtp_email, :mail_password),
                                         }

  routes.default_url_options[:host] = Chamber.dig!(:host)
  config.action_mailer.default_url_options = { :host => Chamber.dig!(:host) }    
```

Then simply use Action Mailer to send the emails.

You will of course need a Mail gun security key etc.

It's a big hacky, but it works :-)

Leave a Reply

Your email address will not be published. Required fields are marked *