How to setup Postfix for Ruby On Rails to send email
Asked Answered
S

2

9

I want to have postfix to send email in my ROR project. As its safer and hax more functionality.

But now I'm quite lost. I installed postfix, got ROR working. But next what should I do?

(I only need to send email, not receive it at the moment)

Should I configure postfix, make it able to send email in comment line first, then integrate it into ROR?

If so, how should I set up the configure file in postfix, and how about settings in rails?

Or do I just need do every setting in rails? If so, what should be the detailed setting?

I'm quite confused. Lots of tutorials either are not working or do not suit my situation.

Sultan answered 27/6, 2014 at 4:25 Comment(0)
H
11

Example Action Mailer Configuration

An example would be adding the following to your appropriate

config/environments/$RAILS_ENV.rb file:

config.action_mailer.delivery_method = :sendmail
# Defaults to:
# config.action_mailer.sendmail_settings = {
#   location: '/usr/sbin/sendmail',
#   arguments: '-i -t'
# }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_options = {from: '[email protected]'}

More information: http://guides.rubyonrails.org/action_mailer_basics.html

Henryk answered 15/9, 2014 at 7:13 Comment(1)
Just in case someone doesn't know: Postfix provides a compatible sendmail binary, so that's why this answer works.Hardwick
E
1

The one below works for me. Paste the snippet in your config/initializers/mail.rb file:

ActionMailer::Base.sendmail_settings = {
        location: "/usr/sbin/sendmail",
        arguments: '-i -t'
}

ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.default charset: "utf-8"
Elkins answered 4/6, 2015 at 10:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.