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

Config: Can add static headers to email messages #79365

Merged
merged 22 commits into from Dec 14, 2023

Conversation

owensmallwood
Copy link
Contributor

@owensmallwood owensmallwood commented Dec 11, 2023

fixes https://github.com/grafana/hosted-grafana/issues/5058

You can add static headers config in the smtp.static_headers section for headers to get added to emails.

Example grafana config could be:

#################################### SMTP / Emailing #####################
[smtp.static_headers]
Foo=value1
Bar=value2

Example
Add the following to your grafana config:

[smtp.static_headers]
Foo-Header=foo_val
Barheader=abc123

Edit: The header validation was updated to only work with smtp headers before I recorded this 👇
Then send an email and inspect the headers:
smtp_static_headers

@owensmallwood owensmallwood changed the title Can add allowed custom headers to an email Message. WIP. Can add allowed static headers to an email Message. WIP. Dec 12, 2023
@owensmallwood owensmallwood marked this pull request as ready for review December 12, 2023 19:12
@owensmallwood owensmallwood requested a review from a team as a code owner December 12, 2023 19:12
@owensmallwood owensmallwood requested review from undef1nd, nikimanoledaki and suntala and removed request for a team December 12, 2023 19:12
@owensmallwood
Copy link
Contributor Author

@hairyhenderson Tested this locally with the smtprelay logging and it works as expected

@owensmallwood owensmallwood changed the title Can add allowed static headers to an email Message. WIP. Config: Can add static headers to email messages Dec 12, 2023
@owensmallwood owensmallwood added the no-backport Skip backport of PR label Dec 12, 2023
@owensmallwood owensmallwood requested a review from a team December 13, 2023 17:09
Copy link
Contributor

@alexweav alexweav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this is looking great! I'll defer to the codeowners of the SMTP service for final approval, but this seems good to me. I had just a couple minor nitpicks.

pkg/services/notifications/smtp.go Show resolved Hide resolved
pkg/setting/setting_smtp.go Outdated Show resolved Hide resolved
Copy link
Member

@hairyhenderson hairyhenderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for working on this @owensmallwood 🥳

@owensmallwood owensmallwood merged commit d5b9602 into main Dec 14, 2023
14 checks passed
@owensmallwood owensmallwood deleted the owensmallwood/can-configure-email-custom-headers branch December 14, 2023 18:59
@summerwollin summerwollin modified the milestones: 10.3.x, 10.3.0 Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants