I want to send acknowledge mail to a particular mail using mailman server. I tried many times to do that. But I did not get any solutions. Please advise me to do the thing.
Asked
Active
Viewed 455 times
2
-
Check out the pro railscasts on this from ryan bates http://railscasts.com/episodes/313-receiving-email-with-mailman – kurenn Dec 30 '14 at 21:33
-
Hey buddy it is not my cup of tea. Because I want to send an acknowledge mail. This is showing how to receive a mail. Is there any other way to achieve this task? – Anitha Dec 31 '14 at 04:40
1 Answers
2
This is very simple:
I like to have an initializer for handle this, like so:
config/initializers/setup_email.rb
if Rails.env.production?
ActionMailer::Base.smtp_settings = {
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => ENV['SENDGRID_DOMAIN'],
:address => "smtp.sendgrid.net",
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
end
And then for the production and development environments you have to do something like so:
config/environments/production.rb
config.action_mailer.default_url_options = { host: "http://www.example.com" }
config.action_mailer.asset_host = "http://www.example.com"
As for the development environment I recommend you install the mailcatcher gem:
$ gem install mailcatcher
Once is installed, run the mailcatcher command:
$ mailcatcher
This will enable a web page on http://127.0.0.1:1080
to where every email will be send and you'll be able to preview them. Just make sure your have the following configuration
config/environments/development.rb
config.action_mailer.default_url_options = { host: "localhost:3000" }
config.action_mailer.asset_host = "http://localhost:3000"
#mailcatcher configs
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
Then you should be fine!

kurenn
- 1,035
- 9
- 11
-
Is this really a correct way to send acknowledge mail?? please don't mistake me. I just asked for clarification – Anitha Jan 02 '15 at 05:10
-
It is a configuration for you to create a mailer and send any kind of email ;) – kurenn Jan 02 '15 at 05:10
-
-
What is the meaning of Sendgrid?? please let me know if u know the ans?? – Anitha Jan 02 '15 at 05:19
-
It is just the email provider, if you are working with heroku to deploy your application is really easy to setup the account, actually to do that you can check http://stackoverflow.com/questions/27402833/why-is-my-heroku-app-not-sending-emails-in-production-with-sendgrid/27406574#27406574 check out the comments! – kurenn Jan 02 '15 at 05:26
-
I just tried it in development mode. after run the mailcatcher, it showed a page contains from,to,subject and received. But I could not able to send any mail. Why so? please advise me – Anitha Jan 02 '15 at 05:37
-
If you want to actually send the email on `development` just remove the conditional from the initializer and set the mailer configuration for development the same as the production...let me know how it goes – kurenn Jan 02 '15 at 06:24
-
1