Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not divide recipients to subgroup when sending attached report #17132

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 9 additions & 27 deletions app/models/miq_report/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,16 @@ def notify_user_of_report(run_on, result, options)
end
end

# Avoid ActionMailer bug where the email headers get corrupted when the total length in bytes of all the recipients exceeds approx 150 bytes.
# When this happens, the addresses on the end spill over into the headers and cause the content and mime information to be ignored.
#
# Split recipient list into groups whose total length in bytes is around 100 bytes or the configured limit
cut_off = ::Settings.smtp.recipient_address_byte_limit
sub_group = []
grouped_tos = to.uniq.inject([]) do |g, t|
sub_group << t
if sub_group.join.length >= cut_off || to.index(t) == (to.length - 1)
g << sub_group
sub_group = []
end
g
end
#

begin
grouped_tos.each do |group_of_tos|
_log.info("Queuing email user: [#{user.name}] report results: [#{result.name}] to: #{group_of_tos.inspect}")
options = {
:to => group_of_tos,
:from => from,
:subject => subject,
:body => body,
:attachment => attachments,
}
GenericMailer.deliver_queue(:generic_notification, options)
end
_log.info("Queuing email user: [#{user.name}] report results: [#{result.name}] to: #{to.inspect}")
options = {
:to => to,
:from => from,
:subject => subject,
:body => body,
:attachment => attachments,
}
GenericMailer.deliver_queue(:generic_notification, options)
rescue => err
_log.error("Queuing email user: [#{user.name}] report results: [#{result.name}] failed with error: [#{err.class.name}] [#{err}]")
end
Expand Down
1 change: 0 additions & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,6 @@
:host: localhost
:password: ''
:port: '25'
:recipient_address_byte_limit: 100
:user_name: evmadmin
:snapshots:
:create_free_percent: 100
Expand Down