Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MailRobot < ActionMailer::Base
- address_to_send_from = ''
- attr_accessor :address_to_send_from
- # Loads the configuration file and configures ActionMailer
- def setup
- c = YAML::load(File.open("#{RAILS_ROOT}/config/config.yml"))
- if c[RAILS_ENV]['email']['server'] == "sendmail"
- ActionMailer::Base.delivery_method = :sendmail
- ActionMailer::Base.sendmail_settings = {
- :location => c[RAILS_ENV]['email']['sendmail_location'],
- :arguments => '-i -t -f ' + c[RAILS_ENV]['email']['address_to_send_from']
- }
- else
- ActionMailer::Base.server_settings = {
- :address => c[RAILS_ENV]['email']['server'],
- :port => c[RAILS_ENV]['email']['port'],
- :domain => c[RAILS_ENV]['email']['domain'],
- :authentication => c[RAILS_ENV]['email']['authentication'],
- :user_name => c[RAILS_ENV]['email']['username'],
- :password => c[RAILS_ENV]['email']['password']
- }
- end
- self.address_to_send_from = c[RAILS_ENV]['email']['address_to_send_from']
- end
- end
- # config/config.yml
- development:
- email:
- server: sendmail
- port: 25
- domain: comcast.net
- authentication: none
- username:
- password:
- address_to_send_from: no-reply@site.com
- sendmail_location: /usr/sbin/sendmail
- production:
- email:
- server: smtp.comcast.net
- port: 25
- domain: comcast.net
- authentication: none
- username:
- password:
- address_to_send_from: no-reply@site.com
- sendmail_location: /usr/sbin/sendmail
Add Comment
Please, Sign In to add comment