diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb
new file mode 100644
index 000000000..e50e74f44
--- /dev/null
+++ b/app/helpers/mailer_helper.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+# Redmine - project management software
+# Copyright (C) 2006-2022 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module MailerHelper
+ def show_recipients(recipients)
+ recipients.take(Setting.show_recipients_limit.to_i).map(&:name).join(', ') + (recipients.size > Setting.show_recipients_limit.to_i ? '...' : '')
+ end
+end
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 558c280ec..12b06b6d6 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -24,6 +24,7 @@ class Mailer < ActionMailer::Base
helper :application
helper :issues
helper :custom_fields
+ helper :mailer
include Redmine::I18n
include Roadie::Rails::Automatic
@@ -70,7 +71,7 @@ def self.default_url_options
end
# Builds a mail for notifying user about a new issue
- def issue_add(user, issue)
+ def issue_add(user, issue, recipients=nil)
redmine_headers 'Project' => issue.project.identifier,
'Issue-Tracker' => issue.tracker.name,
'Issue-Id' => issue.id,
@@ -82,6 +83,7 @@ def issue_add(user, issue)
@author = issue.author
@issue = issue
@user = user
+ @recipients = recipients
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]"
subject += " (#{issue.status.name})" if Setting.show_status_changes_in_mail_subject?
@@ -97,12 +99,12 @@ def issue_add(user, issue)
def self.deliver_issue_add(issue)
users = issue.notified_users | issue.notified_watchers | issue.notified_mentions
users.each do |user|
- issue_add(user, issue).deliver_later
+ issue_add(user, issue, users).deliver_later
end
end
# Builds a mail for notifying user about an issue update
- def issue_edit(user, journal)
+ def issue_edit(user, journal, recipients=nil)
issue = journal.journalized
redmine_headers 'Project' => issue.project.identifier,
'Issue-Tracker' => issue.tracker.name,
@@ -118,6 +120,7 @@ def issue_edit(user, journal)
s += issue.subject
@issue = issue
@user = user
+ @recipients = recipients
@journal = journal
@journal_details = journal.visible_details
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
@@ -136,16 +139,17 @@ def self.deliver_issue_edit(journal)
journal.notes? || journal.visible_details(user).any?
end
users.each do |user|
- issue_edit(user, journal).deliver_later
+ issue_edit(user, journal, users).deliver_later
end
end
# Builds a mail to user about a new document.
- def document_added(user, document, author)
+ def document_added(user, document, author, recipients=nil)
redmine_headers 'Project' => document.project.identifier
@author = author
@document = document
@user = user
+ @recipients = recipients
@document_url = url_for(:controller => 'documents', :action => 'show', :id => document)
mail :to => user,
:subject => "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
@@ -158,12 +162,12 @@ def document_added(user, document, author)
def self.deliver_document_added(document, author)
users = document.notified_users
users.each do |user|
- document_added(user, document, author).deliver_later
+ document_added(user, document, author, users).deliver_later
end
end
# Builds a mail to user about new attachements.
- def attachments_added(user, attachments)
+ def attachments_added(user, attachments, recipients=nil)
container = attachments.first.container
added_to = ''
added_to_url = ''
@@ -182,6 +186,7 @@ def attachments_added(user, attachments)
redmine_headers 'Project' => container.project.identifier
@attachments = attachments
@user = user
+ @recipients = recipients
@added_to = added_to
@added_to_url = added_to_url
mail :to => user,
@@ -202,18 +207,19 @@ def self.deliver_attachments_added(attachments)
end
users.each do |user|
- attachments_added(user, attachments).deliver_later
+ attachments_added(user, attachments, users).deliver_later
end
end
# Builds a mail to user about a new news.
- def news_added(user, news)
+ def news_added(user, news, recipients=nil)
redmine_headers 'Project' => news.project.identifier
@author = news.author
message_id news
references news
@news = news
@user = user
+ @recipients = recipients
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
mail :to => user,
:subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
@@ -226,12 +232,12 @@ def news_added(user, news)
def self.deliver_news_added(news)
users = news.notified_users | news.notified_watchers_for_added_news
users.each do |user|
- news_added(user, news).deliver_later
+ news_added(user, news, users).deliver_later
end
end
# Builds a mail to user about a new news comment.
- def news_comment_added(user, comment)
+ def news_comment_added(user, comment, recipients=nil)
news = comment.commented
redmine_headers 'Project' => news.project.identifier
@author = comment.author
@@ -240,6 +246,7 @@ def news_comment_added(user, comment)
@news = news
@comment = comment
@user = user
+ @recipients = recipients
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
mail :to => user,
:subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}"
@@ -253,12 +260,12 @@ def self.deliver_news_comment_added(comment)
news = comment.commented
users = news.notified_users | news.notified_watchers
users.each do |user|
- news_comment_added(user, comment).deliver_later
+ news_comment_added(user, comment, users).deliver_later
end
end
# Builds a mail to user about a new message.
- def message_posted(user, message)
+ def message_posted(user, message, recipients=nil)
redmine_headers 'Project' => message.project.identifier,
'Topic-Id' => (message.parent_id || message.id)
@author = message.author
@@ -266,6 +273,7 @@ def message_posted(user, message)
references message.root
@message = message
@user = user
+ @recipients = recipients
@message_url = url_for(message.event_url)
mail :to => user,
:subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}"
@@ -281,18 +289,19 @@ def self.deliver_message_posted(message)
users |= message.board.notified_watchers
users.each do |user|
- message_posted(user, message).deliver_later
+ message_posted(user, message, users).deliver_later
end
end
# Builds a mail to user about a new wiki content.
- def wiki_content_added(user, wiki_content)
+ def wiki_content_added(user, wiki_content, recipients=nil)
redmine_headers 'Project' => wiki_content.project.identifier,
'Wiki-Page-Id' => wiki_content.page.id
@author = wiki_content.author
message_id wiki_content
@wiki_content = wiki_content
@user = user
+ @recipients = recipients
@wiki_content_url = url_for(:controller => 'wiki', :action => 'show',
:project_id => wiki_content.project,
:id => wiki_content.page.title)
@@ -310,18 +319,19 @@ def wiki_content_added(user, wiki_content)
def self.deliver_wiki_content_added(wiki_content)
users = wiki_content.notified_users | wiki_content.page.wiki.notified_watchers | wiki_content.notified_mentions
users.each do |user|
- wiki_content_added(user, wiki_content).deliver_later
+ wiki_content_added(user, wiki_content, users).deliver_later
end
end
# Builds a mail to user about an update of the specified wiki content.
- def wiki_content_updated(user, wiki_content)
+ def wiki_content_updated(user, wiki_content, recipients=nil)
redmine_headers 'Project' => wiki_content.project.identifier,
'Wiki-Page-Id' => wiki_content.page.id
@author = wiki_content.author
message_id wiki_content
@wiki_content = wiki_content
@user = user
+ @recipients = recipients
@wiki_content_url =
url_for(:controller => 'wiki', :action => 'show',
:project_id => wiki_content.project,
@@ -348,7 +358,7 @@ def self.deliver_wiki_content_updated(wiki_content)
users |= wiki_content.notified_mentions
users.each do |user|
- wiki_content_updated(user, wiki_content).deliver_later
+ wiki_content_updated(user, wiki_content, users).deliver_later
end
end
@@ -367,8 +377,9 @@ def self.deliver_account_information(user, password)
end
# Builds a mail to user about an account activation request.
- def account_activation_request(user, new_user)
+ def account_activation_request(user, new_user, recipients=nil)
@new_user = new_user
+ @recipients = recipients
@url = url_for(:controller => 'users', :action => 'index',
:status => User::STATUS_REGISTERED,
:sort_key => 'created_on', :sort_order => 'desc')
@@ -385,7 +396,7 @@ def self.deliver_account_activation_request(new_user)
# Send the email to all active administrators
users = User.active.where(:admin => true)
users.each do |user|
- account_activation_request(user, new_user).deliver_later
+ account_activation_request(user, new_user, users.to_a).deliver_later
end
end
@@ -469,7 +480,8 @@ def self.deliver_register(user, token)
# field: :field_mail,
# value: address
# ) => Mail::Message object
- def security_notification(user, sender, options={})
+ def security_notification(user, sender, options={}, recipients=nil)
+ @recipients = recipients
@sender = sender
redmine_headers 'Sender' => sender.login
@message =
@@ -506,12 +518,13 @@ def self.deliver_security_notification(users, sender, options={})
options[:remote_ip] ||= sender.remote_ip
Array.wrap(users).each do |user|
- security_notification(user, sender, options).deliver_later
+ security_notification(user, sender, options, users).deliver_later
end
end
# Build a mail to user about application settings changes made by sender.
- def settings_updated(user, sender, changes, options={})
+ def settings_updated(user, sender, changes, options={}, recipients=nil)
+ @recipients = recipients
@sender = sender
redmine_headers 'Sender' => sender.login
@changes = changes
@@ -538,7 +551,7 @@ def self.deliver_settings_updated(sender, changes, options={})
users = User.active.where(admin: true).to_a
users.each do |user|
- settings_updated(user, sender, changes, options).deliver_later
+ settings_updated(user, sender, changes, options, users).deliver_later
end
end
diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb
index fff36c0cb..a9fde2f0d 100644
--- a/app/views/layouts/mailer.html.erb
+++ b/app/views/layouts/mailer.html.erb
@@ -25,6 +25,11 @@ span.footer {
font-size: 0.8em;
font-style: italic;
}
+span.recipients {
+ font-size: 0.8em;
+ font-style: italic;
+ color: #959595;
+}
blockquote { font-style: italic; border-left: 3px solid #e0e0e0; padding-left: 0.6em; margin-left: 0;}
blockquote blockquote { margin-left: 0;}
pre, code {font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace;}
@@ -78,5 +83,11 @@ table, td, th {
<% if Setting.emails_footer.present? -%>
<% end -%>
+<% if Setting.show_recipients_in_mail_footer? && @recipients.present? %>
+
+ <%= l(:text_sent_email_to_recipients) %>
+ <%= show_recipients @recipients %>
+
+<% end %>