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.
Go to the config folder of your emails project and open environment. rb file and add the following line at the bottom of this file. It tells ActionMailer that you want to use the SMTP server. You can also set it to be :sendmail if you are using a Unix-based operating system such as Mac OS X or Linux.
The default_url_options setting is useful for constructing link URLs in email templates. Usually, the :host , i.e. the fully qualified name of the web server, is needed to be set up with this config option. It has nothing to do with sending emails, it only configures displaying links in the emails.
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
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With