mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +01:00
Compare commits
24 commits
d7b32480fd
...
e808e0b972
Author | SHA1 | Date | |
---|---|---|---|
e808e0b972 | |||
22f56a0143 | |||
d16ae61f64 | |||
5e5bcef696 | |||
7b600534ea | |||
842d4373f2 | |||
5c2831c331 | |||
4fe9022815 | |||
4f97cd8261 | |||
9e51dba82a | |||
cf117d320b | |||
42c63791ef | |||
f5279cd584 | |||
ef3f103c30 | |||
ae15a12ce5 | |||
ea5b02bfdd | |||
591425bb99 | |||
007286fc5e | |||
5b602be818 | |||
96d45c26bc | |||
953a4b4df1 | |||
f079ea09eb | |||
03cb09c3bd | |||
855d7f0867 |
4 changed files with 1984 additions and 791 deletions
|
@ -1261,14 +1261,13 @@ 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{
|
||||
|
|
|
@ -3527,6 +3527,9 @@ 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)
|
||||
}
|
||||
|
|
38
msg.go
38
msg.go
|
@ -847,7 +847,16 @@ 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 {
|
||||
return m.Cc(strings.Split(rcpts, ",")...)
|
||||
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...)
|
||||
}
|
||||
|
||||
// Bcc sets one or more "BCC" (blind carbon copy) addresses in the mail body for the Msg.
|
||||
|
@ -933,7 +942,16 @@ 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 {
|
||||
return m.Bcc(strings.Split(rcpts, ",")...)
|
||||
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...)
|
||||
}
|
||||
|
||||
// ReplyTo sets the "Reply-To" address for the Msg, specifying where replies should be sent.
|
||||
|
@ -1069,8 +1087,7 @@ 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() {
|
||||
now := time.Now().Format(time.RFC1123Z)
|
||||
m.SetGenHeader(HeaderDate, now)
|
||||
m.SetDateWithValue(time.Now())
|
||||
}
|
||||
|
||||
// SetDateWithValue sets the "Date" header for the Msg using the provided time value in a valid RFC 1123 format.
|
||||
|
@ -1170,6 +1187,9 @@ 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)
|
||||
|
@ -1178,9 +1198,7 @@ func (m *Msg) RequestMDNTo(rcpts ...string) error {
|
|||
}
|
||||
addresses = append(addresses, address.String())
|
||||
}
|
||||
if _, ok := m.genHeader[HeaderDispositionNotificationTo]; ok {
|
||||
m.genHeader[HeaderDispositionNotificationTo] = addresses
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -1219,11 +1237,11 @@ func (m *Msg) RequestMDNAddTo(rcpt string) error {
|
|||
return fmt.Errorf(errParseMailAddr, rcpt, err)
|
||||
}
|
||||
var addresses []string
|
||||
addresses = append(addresses, m.genHeader[HeaderDispositionNotificationTo]...)
|
||||
addresses = append(addresses, address.String())
|
||||
if _, ok := m.genHeader[HeaderDispositionNotificationTo]; ok {
|
||||
m.genHeader[HeaderDispositionNotificationTo] = addresses
|
||||
if current, ok := m.genHeader[HeaderDispositionNotificationTo]; ok {
|
||||
addresses = current
|
||||
}
|
||||
addresses = append(addresses, address.String())
|
||||
m.genHeader[HeaderDispositionNotificationTo] = addresses
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
2729
msg_test.go
2729
msg_test.go
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue