base_email_outbound.rb 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. # Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. class Channel::Driver::BaseEmailOutbound
  3. include Channel::EmailHelper
  4. # We're using the same timeouts like in Net::SMTP gem
  5. # but we would like to have the possibility to mock them for tests
  6. DEFAULT_OPEN_TIMEOUT = 30.seconds
  7. DEFAULT_READ_TIMEOUT = 60.seconds
  8. def deliver(_options, _attr, _notification = false) # rubocop:disable Style/OptionalBooleanParameter
  9. raise 'not implemented'
  10. end
  11. def prepare_message_attrs(attr)
  12. # set system_bcc of config if defined
  13. system_bcc = Setting.get('system_bcc')
  14. email_address_validation = EmailAddressValidation.new(system_bcc)
  15. if system_bcc.present? && email_address_validation.valid?
  16. attr[:bcc] ||= ''
  17. attr[:bcc] += ', ' if attr[:bcc].present?
  18. attr[:bcc] += system_bcc
  19. end
  20. prepare_idn_outbound(attr)
  21. end
  22. def deliver_mail(attr, notification, method, options)
  23. mail = Channel::EmailBuild.build(attr, notification)
  24. mail.delivery_method method, options
  25. mail.deliver
  26. end
  27. end