Guest User

Untitled

a guest
Mar 10th, 2018
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. class MailRobot < ActionMailer::Base
  2. address_to_send_from = ''
  3. attr_accessor :address_to_send_from
  4.  
  5. # Loads the configuration file and configures ActionMailer
  6. def setup
  7. c = YAML::load(File.open("#{RAILS_ROOT}/config/config.yml"))
  8.  
  9. if c[RAILS_ENV]['email']['server'] == "sendmail"
  10.  
  11. ActionMailer::Base.delivery_method = :sendmail
  12. ActionMailer::Base.sendmail_settings = {
  13. :location => c[RAILS_ENV]['email']['sendmail_location'],
  14. :arguments => '-i -t -f ' + c[RAILS_ENV]['email']['address_to_send_from']
  15. }
  16.  
  17. else
  18.  
  19. ActionMailer::Base.server_settings = {
  20. :address => c[RAILS_ENV]['email']['server'],
  21. :port => c[RAILS_ENV]['email']['port'],
  22. :domain => c[RAILS_ENV]['email']['domain'],
  23. :authentication => c[RAILS_ENV]['email']['authentication'],
  24. :user_name => c[RAILS_ENV]['email']['username'],
  25. :password => c[RAILS_ENV]['email']['password']
  26. }
  27.  
  28. end
  29.  
  30. self.address_to_send_from = c[RAILS_ENV]['email']['address_to_send_from']
  31. end
  32. end
  33.  
  34. # config/config.yml
  35. development:
  36. email:
  37. server: sendmail
  38. port: 25
  39. domain: comcast.net
  40. authentication: none
  41. username:
  42. password:
  43. address_to_send_from: no-reply@site.com
  44. sendmail_location: /usr/sbin/sendmail
  45. production:
  46. email:
  47. server: smtp.comcast.net
  48. port: 25
  49. domain: comcast.net
  50. authentication: none
  51. username:
  52. password:
  53. address_to_send_from: no-reply@site.com
  54. sendmail_location: /usr/sbin/sendmail
Add Comment
Please, Sign In to add comment