Compare commits

..

No commits in common. "e808e0b972ef61d243282e70cc10e16dfe4399fd" and "d7b32480fdeb0d2607c076c1e4e7399c178813c7" have entirely different histories.

4 changed files with 791 additions and 1984 deletions

View file

@ -1261,13 +1261,14 @@ func (c *Client) sendSingleMsg(message *Msg) error {
affectedMsg: message,
}
}
message.isDelivered = true
if err = writer.Close(); err != nil {
return &SendError{
Reason: ErrSMTPDataClose, errlist: []error{err}, isTemp: isTempError(err),
affectedMsg: message,
}
}
message.isDelivered = true
if err = c.Reset(); err != nil {
return &SendError{

View file

@ -3527,9 +3527,6 @@ func parseJSONLog(t *testing.T, buf *bytes.Buffer) logData {
func testMessage(t *testing.T) *Msg {
t.Helper()
message := NewMsg()
if message == nil {
t.Fatal("failed to create new message")
}
if err := message.From(TestSenderValid); err != nil {
t.Errorf("failed to set sender address: %s", err)
}

36
msg.go
View file

@ -847,16 +847,7 @@ func (m *Msg) CcIgnoreInvalid(rcpts ...string) {
// References:
// - https://datatracker.ietf.org/doc/html/rfc5322#section-3.6.3
func (m *Msg) CcFromString(rcpts string) error {
src := strings.Split(rcpts, ",")
var dst []string
for _, address := range src {
address = strings.TrimSpace(address)
if address == "" {
continue
}
dst = append(dst, address)
}
return m.Cc(dst...)
return m.Cc(strings.Split(rcpts, ",")...)
}
// Bcc sets one or more "BCC" (blind carbon copy) addresses in the mail body for the Msg.
@ -942,16 +933,7 @@ func (m *Msg) BccIgnoreInvalid(rcpts ...string) {
// References:
// - https://datatracker.ietf.org/doc/html/rfc5322#section-3.6.3
func (m *Msg) BccFromString(rcpts string) error {
src := strings.Split(rcpts, ",")
var dst []string
for _, address := range src {
address = strings.TrimSpace(address)
if address == "" {
continue
}
dst = append(dst, address)
}
return m.Bcc(dst...)
return m.Bcc(strings.Split(rcpts, ",")...)
}
// ReplyTo sets the "Reply-To" address for the Msg, specifying where replies should be sent.
@ -1087,7 +1069,8 @@ func (m *Msg) SetBulk() {
// - https://datatracker.ietf.org/doc/html/rfc5322#section-3.3
// - https://datatracker.ietf.org/doc/html/rfc1123
func (m *Msg) SetDate() {
m.SetDateWithValue(time.Now())
now := time.Now().Format(time.RFC1123Z)
m.SetGenHeader(HeaderDate, now)
}
// SetDateWithValue sets the "Date" header for the Msg using the provided time value in a valid RFC 1123 format.
@ -1187,9 +1170,6 @@ func (m *Msg) IsDelivered() bool {
// References:
// - https://datatracker.ietf.org/doc/html/rfc8098
func (m *Msg) RequestMDNTo(rcpts ...string) error {
if m.genHeader == nil {
m.genHeader = make(map[Header][]string)
}
var addresses []string
for _, addrVal := range rcpts {
address, err := mail.ParseAddress(addrVal)
@ -1198,7 +1178,9 @@ func (m *Msg) RequestMDNTo(rcpts ...string) error {
}
addresses = append(addresses, address.String())
}
if _, ok := m.genHeader[HeaderDispositionNotificationTo]; ok {
m.genHeader[HeaderDispositionNotificationTo] = addresses
}
return nil
}
@ -1237,11 +1219,11 @@ func (m *Msg) RequestMDNAddTo(rcpt string) error {
return fmt.Errorf(errParseMailAddr, rcpt, err)
}
var addresses []string
if current, ok := m.genHeader[HeaderDispositionNotificationTo]; ok {
addresses = current
}
addresses = append(addresses, m.genHeader[HeaderDispositionNotificationTo]...)
addresses = append(addresses, address.String())
if _, ok := m.genHeader[HeaderDispositionNotificationTo]; ok {
m.genHeader[HeaderDispositionNotificationTo] = addresses
}
return nil
}

File diff suppressed because it is too large Load diff