email_helper.rb 733 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. module Channel::EmailHelper
  3. PARTICIPANTS = %i[from to cc bcc reply-to return-path sender
  4. resent-from resent-to resent-bcc
  5. delivered-to x-original-to envelope-to].freeze
  6. def prepare_idn_outbound(mail)
  7. prepare_idn(mail, 'to_ascii')
  8. end
  9. def prepare_idn_inbound(mail)
  10. prepare_idn(mail, 'to_unicode')
  11. end
  12. private
  13. def prepare_idn(mail, action)
  14. PARTICIPANTS.each do |participant|
  15. next if !mail[participant]
  16. mail[participant] = mail[participant]
  17. .split(', ')
  18. .map { |address| EmailHelper::Idn.send(action, address) }
  19. .join(', ')
  20. end
  21. mail
  22. end
  23. end