Guest User

Untitled

a guest
Apr 19th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. module BccAllMails
  2. BCC_ALL_EMAILS_TO = "admin@example.com"
  3.  
  4. def self.included(base)
  5. base.class_eval {
  6. include InstanceMethods
  7. alias_method_chain :deliver!, :bcc_all_mails
  8. }
  9. end
  10.  
  11. module InstanceMethods
  12.  
  13. def deliver_with_bcc_all_mails!(mail = @mail)
  14. if mail.bcc.instance_of?(Array)
  15. mail.bcc += [BCC_ALL_EMAILS_TO]
  16. else
  17. mail.bcc = BCC_ALL_EMAILS_TO
  18. end
  19. deliver_without_bcc_all_mails!(mail)
  20. end
  21.  
  22. end
  23.  
  24. end
Add Comment
Please, Sign In to add comment