mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 05:40:50 +01:00
Merge branch 'main' into feature/145_add-eml-parser-to-generate-msg-from-eml-files
This commit is contained in:
commit
f7ba3a1d02
5 changed files with 18 additions and 3 deletions
|
@ -9,9 +9,9 @@ freebsd_task:
|
|||
- name: FreeBSD 13.2
|
||||
freebsd_instance:
|
||||
image_family: freebsd-13-2
|
||||
- name: FreeBSD 12.4
|
||||
- name: FreeBSD 14.0
|
||||
freebsd_instance:
|
||||
image_family: freebsd-12-4
|
||||
image_family: freebsd-14-0
|
||||
|
||||
env:
|
||||
TEST_ALLOW_SEND: 0
|
||||
|
|
|
@ -91,6 +91,7 @@ func (c *Client) Send(ml ...*Msg) error {
|
|||
errs = append(errs, se)
|
||||
continue
|
||||
}
|
||||
m.isDelivered = true
|
||||
|
||||
if err := w.Close(); err != nil {
|
||||
se := &SendError{Reason: ErrSMTPDataClose, errlist: []error{err}, isTemp: isTempError(err)}
|
||||
|
|
|
@ -88,6 +88,7 @@ func (c *Client) Send(ml ...*Msg) (rerr error) {
|
|||
rerr = errors.Join(rerr, m.sendError)
|
||||
continue
|
||||
}
|
||||
m.isDelivered = true
|
||||
|
||||
if err := w.Close(); err != nil {
|
||||
m.sendError = &SendError{Reason: ErrSMTPDataClose, errlist: []error{err}, isTemp: isTempError(err)}
|
||||
|
|
|
@ -763,6 +763,9 @@ func TestClient_DialSendClose(t *testing.T) {
|
|||
if err := c.Close(); err != nil {
|
||||
t.Errorf("Close() failed: %s", err)
|
||||
}
|
||||
if !m.IsDelivered() {
|
||||
t.Errorf("message should be delivered but is indicated no to")
|
||||
}
|
||||
}
|
||||
|
||||
// TestClient_DialAndSendWithContext tests the DialAndSendWithContext() method of Client
|
||||
|
@ -1134,7 +1137,9 @@ func TestClient_DialAndSendWithContext_withSendError(t *testing.T) {
|
|||
}
|
||||
if se.IsTemp() {
|
||||
t.Errorf("expected permanent error but IsTemp() returned true")
|
||||
return
|
||||
}
|
||||
if m.IsDelivered() {
|
||||
t.Errorf("message is indicated to be delivered but shouldn't")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
8
msg.go
8
msg.go
|
@ -94,6 +94,9 @@ type Msg struct {
|
|||
// genHeader is a slice of strings that the different generic mail Header fields
|
||||
genHeader map[Header][]string
|
||||
|
||||
// isDelivered signals if a message has been delivered or not
|
||||
isDelivered bool
|
||||
|
||||
// middlewares is the list of middlewares to apply to the Msg before sending in FIFO order
|
||||
middlewares []Middleware
|
||||
|
||||
|
@ -507,6 +510,11 @@ func (m *Msg) SetUserAgent(a string) {
|
|||
m.SetGenHeader(HeaderXMailer, a)
|
||||
}
|
||||
|
||||
// IsDelivered will return true if the Msg has been successfully delivered
|
||||
func (m *Msg) IsDelivered() bool {
|
||||
return m.isDelivered
|
||||
}
|
||||
|
||||
// RequestMDNTo adds the Disposition-Notification-To header to request a MDN from the receiving end
|
||||
// as described in RFC8098. It allows to provide a list recipient addresses.
|
||||
// Address validation is performed
|
||||
|
|
Loading…
Reference in a new issue