added mailer.Message.InlineAttachments field
This commit is contained in:
parent
2b2dafaf88
commit
239daf2023
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
- Added `app.FindCachedCollectionReferences(collection, excludeIds)` to speedup records cascade delete almost twice for projects with many collections.
|
- Added `app.FindCachedCollectionReferences(collection, excludeIds)` to speedup records cascade delete almost twice for projects with many collections.
|
||||||
|
|
||||||
|
- Added `mailer.Message.InlineAttachments` field for attaching inline files to an email (_aka. `cid` links_).
|
||||||
|
|
||||||
- ⚠️ Removed the "dry submit" when executing the collections Create API rule
|
- ⚠️ Removed the "dry submit" when executing the collections Create API rule
|
||||||
(you can find more details why this change was introduced and how it could affect your app in https://github.com/pocketbase/pocketbase/discussions/6073).
|
(you can find more details why this change was introduced and how it could affect your app in https://github.com/pocketbase/pocketbase/discussions/6073).
|
||||||
For most users it should be non-breaking change, BUT if you have Create API rules that uses self-references or view counters you may have to adjust them manually.
|
For most users it should be non-breaking change, BUT if you have Create API rules that uses self-references or view counters you may have to adjust them manually.
|
||||||
|
|
|
@ -464,7 +464,7 @@ func TestBaseBindsMailerMessage(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
expected := `{"from":{"Name":"test_from","Address":"test_from@example.com"},"to":[{"Name":"test_to1","Address":"test_to1@example.com"},{"Name":"test_to2","Address":"test_to2@example.com"}],"bcc":[{"Name":"test_bcc1","Address":"test_bcc1@example.com"},{"Name":"test_bcc2","Address":"test_bcc2@example.com"}],"cc":[{"Name":"test_cc1","Address":"test_cc1@example.com"},{"Name":"test_cc2","Address":"test_cc2@example.com"}],"subject":"test_subject","html":"test_html","text":"test_text","headers":{"header1":"a","header2":"b"},"attachments":null}`
|
expected := `{"from":{"Name":"test_from","Address":"test_from@example.com"},"to":[{"Name":"test_to1","Address":"test_to1@example.com"},{"Name":"test_to2","Address":"test_to2@example.com"}],"bcc":[{"Name":"test_bcc1","Address":"test_bcc1@example.com"},{"Name":"test_bcc2","Address":"test_bcc2@example.com"}],"cc":[{"Name":"test_cc1","Address":"test_cc1@example.com"},{"Name":"test_cc2","Address":"test_cc2@example.com"}],"subject":"test_subject","html":"test_html","text":"test_text","headers":{"header1":"a","header2":"b"},"attachments":null,"inlineAttachments":null}`
|
||||||
|
|
||||||
if string(raw) != expected {
|
if string(raw) != expected {
|
||||||
t.Fatalf("Expected \n%s, \ngot \n%s", expected, raw)
|
t.Fatalf("Expected \n%s, \ngot \n%s", expected, raw)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9,15 +9,16 @@ import (
|
||||||
|
|
||||||
// Message defines a generic email message struct.
|
// Message defines a generic email message struct.
|
||||||
type Message struct {
|
type Message struct {
|
||||||
From mail.Address `json:"from"`
|
From mail.Address `json:"from"`
|
||||||
To []mail.Address `json:"to"`
|
To []mail.Address `json:"to"`
|
||||||
Bcc []mail.Address `json:"bcc"`
|
Bcc []mail.Address `json:"bcc"`
|
||||||
Cc []mail.Address `json:"cc"`
|
Cc []mail.Address `json:"cc"`
|
||||||
Subject string `json:"subject"`
|
Subject string `json:"subject"`
|
||||||
HTML string `json:"html"`
|
HTML string `json:"html"`
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
Headers map[string]string `json:"headers"`
|
Headers map[string]string `json:"headers"`
|
||||||
Attachments map[string]io.Reader `json:"attachments"`
|
Attachments map[string]io.Reader `json:"attachments"`
|
||||||
|
InlineAttachments map[string]io.Reader `json:"inlineAttachments"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mailer defines a base mail client interface.
|
// Mailer defines a base mail client interface.
|
||||||
|
|
|
@ -114,11 +114,16 @@ func (c *SMTPClient) send(m *Message) error {
|
||||||
yak.Cc(addressesToStrings(m.Cc, true)...)
|
yak.Cc(addressesToStrings(m.Cc, true)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// add attachements (if any)
|
// add regular attachements (if any)
|
||||||
for name, data := range m.Attachments {
|
for name, data := range m.Attachments {
|
||||||
yak.Attach(name, data)
|
yak.Attach(name, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add inline attachments (if any)
|
||||||
|
for name, data := range m.InlineAttachments {
|
||||||
|
yak.AttachInline(name, data)
|
||||||
|
}
|
||||||
|
|
||||||
// add custom headers (if any)
|
// add custom headers (if any)
|
||||||
var hasMessageId bool
|
var hasMessageId bool
|
||||||
for k, v := range m.Headers {
|
for k, v := range m.Headers {
|
||||||
|
|
Loading…
Reference in New Issue