How to send Verification E-Mail in Development Mode

(Nitish Kokari) #1

This is my first post. I would like to know how to send E-Mails in Development mode since I am trying to add new features and running in the local server. Getting some difficulties since I am unable to get the mails i require. I can use the MailCatcher, but need genuine method to receive mails.

(Sam Saffron) #2

Why is mailcatcher not working for you? you can always change the ports etc in environments/development.rb if you must.

(Simon Cossar) #3

If you’re using MailCatcher and you want to see the emails on an actual email client, you can download the .emi files from MailCatcher and then send them to yourself using the Mandrill API. It takes a bit of work to set it up, but it’s probably easier than setting up a mail server.

(Simon Cossar) #4

It’s easier than this. You can configure rails to send development emails with Mandrill. To avoid exposing your credentials on github, make a .env file and add dotenv rails to your Gemfile.
SMTP_PASSWORD= your mandrill_api_key
SMTP_USERNAME= your mandrill_username

And then add this to config/development.rb

# config/development.rb
config.action_mailer.smtp_settings = {
    address: ENV.fetch("SMTP_ADDRESS"),
    authentication: :plain,
    domain: ENV.fetch("SMTP_DOMAIN"),
    enable_starttls_auto: true,
    password: ENV.fetch("SMTP_PASSWORD"),
    port: "587",
    user_name: ENV.fetch("SMTP_USERNAME")
config.action_mailer.default_url_options = { host: ENV["SMTP_DOMAIN"] }