@@ -1530,7 +1530,7 @@ func TestMsg_ReplyTo(t *testing.T) {
15301530 if err := message .ReplyTo ("toni.tester@example.com" ); err != nil {
15311531 t .Fatalf ("failed to set ReplyTo: %s" , err )
15321532 }
1533- checkGenHeader (t , message , HeaderReplyTo , "ReplyTo" , 0 , 1 , "< toni.tester@example.com> " )
1533+ checkAddrHeader (t , message , HeaderReplyTo , "ReplyTo" , 0 , 1 , "toni.tester@example.com" , " " )
15341534 })
15351535 t .Run ("ReplyTo with invalid address" , func (t * testing.T ) {
15361536 message := NewMsg ()
@@ -1578,7 +1578,7 @@ func TestMsg_ReplyToFormat(t *testing.T) {
15781578 if err := message .ReplyToFormat ("Tina Tester" , "tina.tester@example.com" ); err != nil {
15791579 t .Fatalf ("failed to set ReplyTo: %s" , err )
15801580 }
1581- checkGenHeader (t , message , HeaderReplyTo , "ReplyToFormat" , 0 , 1 , `"Tina Tester" < tina.tester@example.com>` )
1581+ checkAddrHeader (t , message , HeaderReplyTo , "ReplyToFormat" , 0 , 1 , " tina.tester@example.com" , "Tina Tester" )
15821582 })
15831583 t .Run ("ReplyToFormat with invalid address" , func (t * testing.T ) {
15841584 message := NewMsg ()
@@ -1589,6 +1589,29 @@ func TestMsg_ReplyToFormat(t *testing.T) {
15891589 t .Errorf ("ReplyToFormat should fail with invalid address" )
15901590 }
15911591 })
1592+ // https://github.com/wneessen/go-mail/issues/440
1593+ t .Run ("ReplyToFormat with special characters must not double encode" , func (t * testing.T ) {
1594+ message := NewMsg ()
1595+ if message == nil {
1596+ t .Fatal ("message is nil" )
1597+ }
1598+ if err := message .ReplyToFormat ("Töni Tester" , "töni.tester@example.com" ); err != nil {
1599+ t .Errorf ("failed to set ReplyTo: %s" , err )
1600+ }
1601+ buffer := bytes .NewBuffer (nil )
1602+ if _ , err := message .WriteTo (buffer ); err != nil {
1603+ t .Errorf ("failed to write message to buffer: %s" , err )
1604+ }
1605+ header := strings .Split (buffer .String (), "Reply-To: " )
1606+ if len (header ) != 2 {
1607+ t .Fatalf ("could not split message after Reply-To:" )
1608+ }
1609+ want := `=?utf-8?q?T=C3=B6ni_Tester?= <töni.tester@example.com>`
1610+ got := strings .TrimSpace (header [1 ])
1611+ if got != want {
1612+ t .Errorf ("Reply-To header does not match: got %q, want %q" , got , want )
1613+ }
1614+ })
15921615}
15931616
15941617func TestMsg_Subject (t * testing.T ) {
0 commit comments