Implemented issue #2228 - Global Bcc for all outgoing emails for external archive options.

This commit is contained in:
Martin Edenhofer 2018-09-13 09:09:05 +02:00
parent cd93bccfed
commit 54e65e5156
4 changed files with 47 additions and 0 deletions

View file

@ -6,6 +6,14 @@ class Channel::Driver::Sendmail
# return if we run import mode # return if we run import mode
return if Setting.get('import_mode') return if Setting.get('import_mode')
# set system_bcc of config if defined
system_bcc = Setting.get('system_bcc')
if system_bcc.present? && system_bcc =~ /@/
attr[:bcc] ||= ''
attr[:bcc] += ', ' if attr[:bcc].present?
attr[:bcc] += system_bcc
end
mail = Channel::EmailBuild.build(attr, notification) mail = Channel::EmailBuild.build(attr, notification)
mail.delivery_method delivery_method mail.delivery_method delivery_method
mail.deliver mail.deliver

View file

@ -52,6 +52,15 @@ class Channel::Driver::Smtp
if !options.key?(:openssl_verify_mode) if !options.key?(:openssl_verify_mode)
options[:openssl_verify_mode] = 'none' options[:openssl_verify_mode] = 'none'
end end
# set system_bcc of config if defined
system_bcc = Setting.get('system_bcc')
if system_bcc.present? && system_bcc =~ /@/
attr[:bcc] ||= ''
attr[:bcc] += ', ' if attr[:bcc].present?
attr[:bcc] += system_bcc
end
mail = Channel::EmailBuild.build(attr, notification) mail = Channel::EmailBuild.build(attr, notification)
smtp_params = { smtp_params = {
openssl_verify_mode: options[:openssl_verify_mode], openssl_verify_mode: options[:openssl_verify_mode],

View file

@ -0,0 +1,19 @@
class SettingAddSystemBcc < ActiveRecord::Migration[5.1]
def up
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
Setting.create_if_not_exists(
title: 'Bcc address for all outgoing emails',
name: 'system_bcc',
area: 'Email::Enhanced',
description: 'To archive all outgoing emails from Zammad to external, you can store a bcc email address here.',
options: {},
state: '',
preferences: { online_service_disable: true },
frontend: false
)
end
end

View file

@ -2554,6 +2554,17 @@ Setting.create_if_not_exists(
frontend: false frontend: false
) )
Setting.create_if_not_exists(
title: 'Bcc address for all outgoing emails',
name: 'system_bcc',
area: 'Email::Enhanced',
description: 'To archive all outgoing emails from Zammad to external, you can store a bcc email address here.',
options: {},
state: '',
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists( Setting.create_if_not_exists(
title: 'API Token Access', title: 'API Token Access',
name: 'api_token_access', name: 'api_token_access',