[#1069] added default Message-ID and more options to customize the mail message

This commit is contained in:
Gani Georgiev
2022-11-21 14:53:05 +02:00
parent c4a660d2d2
commit 3e1a19685b
11 changed files with 186 additions and 157 deletions
+7 -18
View File
@@ -1,9 +1,6 @@
package tests
import (
"io"
"net/mail"
"github.com/pocketbase/pocketbase/tools/mailer"
)
@@ -11,28 +8,20 @@ var _ mailer.Mailer = (*TestMailer)(nil)
// TestMailer is a mock `mailer.Mailer` implementation.
type TestMailer struct {
TotalSend int
LastFromAddress mail.Address
LastToAddress mail.Address
LastHtmlSubject string
LastHtmlBody string
TotalSend int
LastMessage mailer.Message
}
// Reset clears any previously test collected data.
func (m *TestMailer) Reset() {
m.TotalSend = 0
m.LastFromAddress = mail.Address{}
m.LastToAddress = mail.Address{}
m.LastHtmlSubject = ""
m.LastHtmlBody = ""
m.LastMessage = mailer.Message{}
}
// Send implements `mailer.Mailer` interface.
func (m *TestMailer) Send(fromEmail mail.Address, toEmail mail.Address, subject string, html string, attachments map[string]io.Reader) error {
m.LastFromAddress = fromEmail
m.LastToAddress = toEmail
m.LastHtmlSubject = subject
m.LastHtmlBody = html
m.TotalSend++
func (c *TestMailer) Send(m *mailer.Message) error {
c.TotalSend++
c.LastMessage = *m
return nil
}