Is it possible without user_name & password Action mailer configuration in rails ?

Hi All,

I need to configure SMTP on production,My client only providing address, is that possible without user_name & password to configure SMTP ?

Hi All,

I need to configure SMTP on production,My client only providing address, is that possible without user_name & password to configure SMTP ?

What is your host? If you are using Heroku you can configure SendGrid starter and it will provide a username and password for the mail server it creates for you.

Provision SendGrid like

heroku addons:create sendgrid:starter

Then grab your environment vars with

heroku config:get SENDGRID_USERNAME
heroku config:get SENDGRID_PASSWORD

More information can be found here: https://devcenter.heroku.com/articles/sendgrid

To use the SMTP mailer you will need to setup an initializer class with something like the following:

So, in config/initializers/setup_mail.rb

ActionMailer::Base.delivery_method = :smtp

ActionMailer::Base.smtp_settings = {

:address => ‘smtp.sendgrid.net’,

:port => ‘587’,

:authentication => :plain,

:user_name => ENV[‘SENDGRID_USERNAME’],

:password => ENV[‘SENDGRID_PASSWORD’],

:domain => ‘heroku.com’,

:enable_starttls_auto => true

}

Create a mailer template and invoke from your controller of choice and you’ve got a working mail in production.

Yes it is, although that implies no security, still, if the mail host is internal that can be acceptable, if the mail host is on the Internet, it will still work, but once people find out about an unauthenticatedcserver it will be abused

No, We’re using AWS server, my client only providing :domain and :address

Can you give me some reference configurations, please ?

my client only providing domain name and address

https://aws.amazon.com/marketplace/pp/B074CQY6KB – same service… just on AWS. Worth a look.

You need to expand on ‘AWS Server’

Do you mean a VM running Linux and Sendmail/Postfix??

Do you mean the AWS ‘Simple Email Service’(SES)??

or something else ??

All the configs are different so…

Hi Mike, Thank you for your reply,

We want to configure Redhat Linux and Sendmail / Postfix

Please guide me how to configure via Postfix using my client mailer credentials (they’re not providing user name and password)

Thanks & Regards

Prasanth

It is all fairly well explained in the rails guides however:

If your mailer is on the same box as your web app use something like…

config.action_mailer.delivery_method = :sendmail

config.action_mailer.perform_deliveries = true

config.action_mailer.raise_delivery_errors = true

config.action_mailer.default_options = { from: ‘myapp@mydomain.com’ }

If the sendmail instance is running on a different box, then you have to use SMTP.

Delete the first line above (:sendmail), and replace with

config.action_mailer.delivery_method = :smtp

config.action_mailer.smtp_settings = {

port: 25, # might be 587

address: ‘mymailer.domain.com

}

Thank you Mike, it’s working now