mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 22:00: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,
|
affectedMsg: message,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
message.isDelivered = true
|
|
||||||
|
|
||||||
if err = writer.Close(); err != nil {
|
if err = writer.Close(); err != nil {
|
||||||
return &SendError{
|
return &SendError{
|
||||||
Reason: ErrSMTPDataClose, errlist: []error{err}, isTemp: isTempError(err),
|
Reason: ErrSMTPDataClose, errlist: []error{err}, isTemp: isTempError(err),
|
||||||
affectedMsg: message,
|
affectedMsg: message,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
message.isDelivered = true
|
||||||
|
|
||||||
if err = c.Reset(); err != nil {
|
if err = c.Reset(); err != nil {
|
||||||
return &SendError{
|
return &SendError{
|
||||||
|
|
|
@ -3527,6 +3527,9 @@ func parseJSONLog(t *testing.T, buf *bytes.Buffer) logData {
|
||||||
func testMessage(t *testing.T) *Msg {
|
func testMessage(t *testing.T) *Msg {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
message := NewMsg()
|
message := NewMsg()
|
||||||
|
if message == nil {
|
||||||
|
t.Fatal("failed to create new message")
|
||||||
|
}
|
||||||
if err := message.From(TestSenderValid); err != nil {
|
if err := message.From(TestSenderValid); err != nil {
|
||||||
t.Errorf("failed to set sender address: %s", err)
|
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:
|
// References:
|
||||||
// - https://datatracker.ietf.org/doc/html/rfc5322#section-3.6.3
|
// - https://datatracker.ietf.org/doc/html/rfc5322#section-3.6.3
|
||||||
func (m *Msg) CcFromString(rcpts string) error {
|
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.
|
// 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:
|
// References:
|
||||||
// - https://datatracker.ietf.org/doc/html/rfc5322#section-3.6.3
|
// - https://datatracker.ietf.org/doc/html/rfc5322#section-3.6.3
|
||||||
func (m *Msg) BccFromString(rcpts string) error {
|
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.
|
// 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/rfc5322#section-3.3
|
||||||
// - https://datatracker.ietf.org/doc/html/rfc1123
|
// - https://datatracker.ietf.org/doc/html/rfc1123
|
||||||
func (m *Msg) SetDate() {
|
func (m *Msg) SetDate() {
|
||||||
now := time.Now().Format(time.RFC1123Z)
|
m.SetDateWithValue(time.Now())
|
||||||
m.SetGenHeader(HeaderDate, now)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDateWithValue sets the "Date" header for the Msg using the provided time value in a valid RFC 1123 format.
|
// 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:
|
// References:
|
||||||
// - https://datatracker.ietf.org/doc/html/rfc8098
|
// - https://datatracker.ietf.org/doc/html/rfc8098
|
||||||
func (m *Msg) RequestMDNTo(rcpts ...string) error {
|
func (m *Msg) RequestMDNTo(rcpts ...string) error {
|
||||||
|
if m.genHeader == nil {
|
||||||
|
m.genHeader = make(map[Header][]string)
|
||||||
|
}
|
||||||
var addresses []string
|
var addresses []string
|
||||||
for _, addrVal := range rcpts {
|
for _, addrVal := range rcpts {
|
||||||
address, err := mail.ParseAddress(addrVal)
|
address, err := mail.ParseAddress(addrVal)
|
||||||
|
@ -1178,9 +1198,7 @@ func (m *Msg) RequestMDNTo(rcpts ...string) error {
|
||||||
}
|
}
|
||||||
addresses = append(addresses, address.String())
|
addresses = append(addresses, address.String())
|
||||||
}
|
}
|
||||||
if _, ok := m.genHeader[HeaderDispositionNotificationTo]; ok {
|
|
||||||
m.genHeader[HeaderDispositionNotificationTo] = addresses
|
m.genHeader[HeaderDispositionNotificationTo] = addresses
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1219,11 +1237,11 @@ func (m *Msg) RequestMDNAddTo(rcpt string) error {
|
||||||
return fmt.Errorf(errParseMailAddr, rcpt, err)
|
return fmt.Errorf(errParseMailAddr, rcpt, err)
|
||||||
}
|
}
|
||||||
var addresses []string
|
var addresses []string
|
||||||
addresses = append(addresses, m.genHeader[HeaderDispositionNotificationTo]...)
|
if current, ok := m.genHeader[HeaderDispositionNotificationTo]; ok {
|
||||||
addresses = append(addresses, address.String())
|
addresses = current
|
||||||
if _, ok := m.genHeader[HeaderDispositionNotificationTo]; ok {
|
|
||||||
m.genHeader[HeaderDispositionNotificationTo] = addresses
|
|
||||||
}
|
}
|
||||||
|
addresses = append(addresses, address.String())
|
||||||
|
m.genHeader[HeaderDispositionNotificationTo] = addresses
|
||||||
return nil
|
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