sendmail.rb 788 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. class Channel::Driver::Sendmail
  3. def send(_options, attr, notification = false)
  4. # return if we run import mode
  5. return if Setting.get('import_mode')
  6. # set system_bcc of config if defined
  7. system_bcc = Setting.get('system_bcc')
  8. email_address_validation = EmailAddressValidation.new(system_bcc)
  9. if system_bcc.present? && email_address_validation.valid_format?
  10. attr[:bcc] ||= ''
  11. attr[:bcc] += ', ' if attr[:bcc].present?
  12. attr[:bcc] += system_bcc
  13. end
  14. mail = Channel::EmailBuild.build(attr, notification)
  15. mail.delivery_method delivery_method
  16. mail.deliver
  17. end
  18. private
  19. def delivery_method
  20. return :test if Rails.env.test?
  21. :sendmail
  22. end
  23. end