diff --git a/internal/mailer/templatemailer/templatemailer.go b/internal/mailer/templatemailer/templatemailer.go index bd70476c6..3f5771c3f 100644 --- a/internal/mailer/templatemailer/templatemailer.go +++ b/internal/mailer/templatemailer/templatemailer.go @@ -502,7 +502,14 @@ func getPath(filepath string, params *emailParams) (*url.URL, error) { } } if params != nil { - path.RawQuery = fmt.Sprintf("token=%s&type=%s&redirect_to=%s", url.QueryEscape(params.Token), url.QueryEscape(params.Type), encodeRedirectURL(params.RedirectTo)) + baseQuery := fmt.Sprintf("token=%s&type=%s&redirect_to=%s", url.QueryEscape(params.Token), url.QueryEscape(params.Type), encodeRedirectURL(params.RedirectTo)) + + // Append existing query params if any + if existing := path.RawQuery; existing != "" { + path.RawQuery = fmt.Sprintf("%s&%s", baseQuery, existing) + } else { + path.RawQuery = baseQuery + } } return path, nil } diff --git a/internal/mailer/templatemailer/templatemailer_url_test.go b/internal/mailer/templatemailer/templatemailer_url_test.go index 672d37130..074013cb1 100644 --- a/internal/mailer/templatemailer/templatemailer_url_test.go +++ b/internal/mailer/templatemailer/templatemailer_url_test.go @@ -56,6 +56,12 @@ func TestGetPath(t *testing.T) { Params: ¶ms, Expected: "https://test.example.com?token=token&type=signup&redirect_to=https://example.com", }, + { + SiteURL: "https://test.example.com/", + Path: "/trailingslash?flow=test", + Params: ¶ms, + Expected: "https://test.example.com/trailingslash?token=token&type=signup&redirect_to=https://example.com&flow=test", + }, } for _, c := range cases {