Abhas Arya
Abhas Arya

Reputation: 470

Sending Email in Rails App

I've been trying to create a RoR app that sends an outgoing email, where you can specify the message, subject, etc. I have not installed any type of email server and have no idea how to configure the smtp settings. I want the finished product to look something like this:

http://www.tutorialspoint.com/images/send-email.gif

I am working in a pretty new version of Mac OS X and have been following this tutorial that uses the Action Mailer Class: http://www.tutorialspoint.com/ruby-on-rails/rails-send-email.htm

Unfortunately this tutorial doesn't comply with rails 4.0 so it's a bit dodgy. Anyway, when I set the smtp settings in environment.rb it looks like this:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address:              'smtp.gmail.com',
  port:                 587,
  domain:               'anythingworks',
  user_name:            '[email protected]',
  password:             'mygmailpassword',
  authentication:       'plain',
  enable_starttls_auto: true  }

I actually have no idea what to put for the address, domain, and user_name and passwords. Is there anyway I can send the email from localhost and if so, how would I configure my smtp settings?

Any help would be really appreciated! Thank you in advance

Upvotes: 0

Views: 156

Answers (1)

Yaro
Yaro

Reputation: 568

You can use official guides. So in development.rb you should write:

  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address:              'smtp.gmail.com',
    port:                 587,
    domain:               'yourdomain.com',
    user_name:            'your gmail username',
    password:             'your gmail password',
    authentication:       'plain',
    enable_starttls_auto: true
  }
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true

perform_deliveries option allows you to deliver mail even from localhost.

Upvotes: 1

Related Questions