mirror of
https://github.com/wneessen/go-mail.git
synced 2024-12-22 18:50:37 +01:00
#166: Add delivery status indication for messages
This update introduces a new property, `isDelivered`, in the message struct to track if a message has been successfully sent or not. Additionally, this also includes a new helper function `IsDelivered` to easily retrieve the status. This feature enhances the tracking capabilities of outgoing messages across different client files.
This commit is contained in:
parent
e4927fde82
commit
0b622368ba
3 changed files with 10 additions and 0 deletions
|
@ -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)}
|
||||
|
|
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