Can we use smtp with heroku without the SendGrid add-on?

1.2k views Asked by At

I am deploying an ruby-on-rails app in Heroku.I cannot add the SendGrid add-on to the heroku account.Is there any other ways to use the email services?

2

There are 2 answers

0
Martyn Davies On BEST ANSWER

Yes you can simply sign up for a SendGrid account directly and then use the SMTP details. It would look like this:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
    :address => "smtp.sendgrid.net",
    :port => 587,
    :domain => 'yourdomain.com',
    :user_name => ENV['SENDGRID_USERNAME'],
    :password => ENV['SENDGRID_PASSWORD'],
    :authentication => 'plain',
    :enable_starttls_auto => true 
}

There's also an example using the Mail gem, in the SendGrid documentation.

0
Ojash On

You could use your Gmail account. In config > environment > production.rb

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address => "smtp.gmail.com",
  :port => 587,
  :domain => 'gmail.com',
  :user_name => ENV['GMAIL_USER_NAME'],
  :password => ENV['GMAIL_PASSWORD'],
  :authentication => 'plain',
  :enable_starttls_auto => true 
}

Then you have to set GMAIL_USER_NAME and GMAIL_PASSWORD to Heroku configs

GMAIL_USER_NAME should be your email address of gmail domain eg. [email protected]