Email Configuration SMTP

You can configure email with initializers. Example:


Jets.application.configure do
  config.action_mailer.show_previews = false # default: false
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address:         ENV['SMTP_ADDRESS'],
    port:            587,
    domain:          ENV['SMTP_DOMAIN'],
    authentication:  :login,
    user_name:       ENV['SMTP_USER_NAME'],
    password:        ENV['SMTP_PASSWORD'],
    enable_starttls_auto: true

We can configure the variables with env files. Example:


Testing SMTP

One way to test SMTP server connection is with telnet. Example:

$ telnet 587
Connected to
Escape character is '^]'.
telnet> quit

Note, to escape out of the telnet session you have to use the escape sequence ^]. That’s the control key plus close square bracket key. Then you can type quit.