-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add mail header support via
GOTRUE_SMTP_HEADERS
with `$messag…
…eType` (#1804) Adds support for additional and configurable email message headers. Set the `GOTRUE_SMTP_HEADERS` value to a JSON object of the shape (TypeScript notation) ``` { [header: string]: string[] } ``` Use the special string `$messageType` in the value portion to identify the message type being sent (for now: `invite`, `confirm`, `reauthenticate`, `email_change`, `recovery`, `magiclink`, `other`). To use this with [AWS SES Feedback-ID](https://aws.amazon.com/about-aws/whats-new/2024/06/amazon-ses-custom-values-feedback-header/) one way to do it would be to [set SES SMTP message tags](https://docs.aws.amazon.com/ses/latest/dg/event-publishing-send-email.html#event-publishing-using-ses-headers): ``` GOTRUE_SMTP_HEADERS={"x-ses-message-tags": ["ses:feedback-id-a=<project-ref>,ses:feedback-id-b=$messageType"]} ```
- Loading branch information
Showing
5 changed files
with
108 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package mailer | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/supabase/auth/internal/conf" | ||
) | ||
|
||
func TestTemplateHeaders(t *testing.T) { | ||
mailer := TemplateMailer{ | ||
Config: &conf.GlobalConfiguration{ | ||
SMTP: conf.SMTPConfiguration{ | ||
Headers: `{"X-Test-A": ["test-a", "test-b"], "X-Test-B": ["test-c", "abc $messageType"]}`, | ||
}, | ||
}, | ||
} | ||
|
||
require.NoError(t, mailer.Config.SMTP.Validate()) | ||
|
||
require.Equal(t, mailer.Headers("TEST-MESSAGE-TYPE"), map[string][]string{ | ||
"X-Test-A": {"test-a", "test-b"}, | ||
"X-Test-B": {"test-c", "abc TEST-MESSAGE-TYPE"}, | ||
}) | ||
|
||
require.Equal(t, mailer.Headers("OTHER-TYPE"), map[string][]string{ | ||
"X-Test-A": {"test-a", "test-b"}, | ||
"X-Test-B": {"test-c", "abc OTHER-TYPE"}, | ||
}) | ||
} |