Commit f2dd0084 authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

pipeline-emails: add `To:` header to pipeline mails with unique recipient

See inline comment for more details.

--HG--
branch : heptapod
parent b51171eaff88
......@@ -31,8 +31,19 @@ def pipeline_mail(pipeline, recipients, status)
# We use bcc here because we don't want to generate these emails for a
# thousand times. This could be potentially expensive in a loop, and
# recipients would contain all project watchers so it could be a lot.
mail(bcc: recipients,
subject: pipeline_subject(status)) do |format|
mail_args = { bcc: recipients, subject: pipeline_subject(status) }
if recipients.length == 1
# "Pipeline emails" integration can be used to send notifications of
# failure to mailing-lists. By default, GitLab sends those mails
# without a `To:` header, which trips anti-spam filters for mailing
# lists. This is not a great solution, but a temporary one. A better
# solution is to add a boolean to the UI to say "these emails should
# have a `To:` header".
mail_args[:to] = recipients[0]
end
mail(**mail_args) do |format|
format.html { render layout: 'mailer' }
format.text { render layout: 'mailer' }
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment