forked from pocketbase/pocketbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pocketbase#1728] normalized mailer.Message recipient fields
- Loading branch information
1 parent
69b8012
commit 2378bc7
Showing
9 changed files
with
98 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,26 @@ | |
|
||
- Changed `System.GetFile()` to return directly `*blob.Reader` instead of the `io.ReadCloser` interface. | ||
|
||
- **!** Changed `To`, `Cc` and `Bcc` of `mailer.Message` to `[]mail.Address` for consistency and to allow multiple recipients and optional name. | ||
|
||
If you are sending custom emails, you'll have to replace: | ||
```go | ||
message := &mailer.Message{ | ||
... | ||
|
||
// (old) To: mail.Address{Address: "[email protected]"} | ||
To: []mail.Address{{Address: "[email protected]", Name: "Some optional name"}} | ||
|
||
// (old) Cc: []string{"[email protected]"} | ||
Cc: []mail.Address{{Address: "[email protected]", Name: "Some optional name"}} | ||
|
||
// (old) Bcc: []string{"[email protected]"} | ||
Bcc: []mail.Address{{Address: "[email protected]", Name: "Some optional name"}} | ||
|
||
... | ||
} | ||
``` | ||
|
||
|
||
## v0.12.1 | ||
|
||
|
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 |
---|---|---|
|
@@ -318,8 +318,12 @@ func TestSettingsTestEmail(t *testing.T) { | |
t.Fatalf("[verification] Expected 1 sent email, got %d", app.TestMailer.TotalSend) | ||
} | ||
|
||
if app.TestMailer.LastMessage.To.Address != "[email protected]" { | ||
t.Fatalf("[verification] Expected the email to be sent to %s, got %s", "[email protected]", app.TestMailer.LastMessage.To.Address) | ||
if len(app.TestMailer.LastMessage.To) != 1 { | ||
t.Fatalf("[verification] Expected 1 recipient, got %v", app.TestMailer.LastMessage.To) | ||
} | ||
|
||
if app.TestMailer.LastMessage.To[0].Address != "[email protected]" { | ||
t.Fatalf("[verification] Expected the email to be sent to %s, got %s", "[email protected]", app.TestMailer.LastMessage.To[0].Address) | ||
} | ||
|
||
if !strings.Contains(app.TestMailer.LastMessage.HTML, "Verify") { | ||
|
@@ -349,8 +353,12 @@ func TestSettingsTestEmail(t *testing.T) { | |
t.Fatalf("[password-reset] Expected 1 sent email, got %d", app.TestMailer.TotalSend) | ||
} | ||
|
||
if app.TestMailer.LastMessage.To.Address != "[email protected]" { | ||
t.Fatalf("[password-reset] Expected the email to be sent to %s, got %s", "[email protected]", app.TestMailer.LastMessage.To.Address) | ||
if len(app.TestMailer.LastMessage.To) != 1 { | ||
t.Fatalf("[password-reset] Expected 1 recipient, got %v", app.TestMailer.LastMessage.To) | ||
} | ||
|
||
if app.TestMailer.LastMessage.To[0].Address != "[email protected]" { | ||
t.Fatalf("[password-reset] Expected the email to be sent to %s, got %s", "[email protected]", app.TestMailer.LastMessage.To[0].Address) | ||
} | ||
|
||
if !strings.Contains(app.TestMailer.LastMessage.HTML, "Reset password") { | ||
|
@@ -380,8 +388,12 @@ func TestSettingsTestEmail(t *testing.T) { | |
t.Fatalf("[email-change] Expected 1 sent email, got %d", app.TestMailer.TotalSend) | ||
} | ||
|
||
if app.TestMailer.LastMessage.To.Address != "[email protected]" { | ||
t.Fatalf("[email-change] Expected the email to be sent to %s, got %s", "[email protected]", app.TestMailer.LastMessage.To.Address) | ||
if len(app.TestMailer.LastMessage.To) != 1 { | ||
t.Fatalf("[email-change] Expected 1 recipient, got %v", app.TestMailer.LastMessage.To) | ||
} | ||
|
||
if app.TestMailer.LastMessage.To[0].Address != "[email protected]" { | ||
t.Fatalf("[email-change] Expected the email to be sent to %s, got %s", "[email protected]", app.TestMailer.LastMessage.To[0].Address) | ||
} | ||
|
||
if !strings.Contains(app.TestMailer.LastMessage.HTML, "Confirm new email") { | ||
|
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
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