Skip to content

Commit

Permalink
if local part is just postmaster, String() returns postmaster #199
Browse files Browse the repository at this point in the history
  • Loading branch information
flashmob committed Dec 13, 2019
1 parent 97a8f88 commit 2a405ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions mail/envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func (a *Address) String() string {
if a.IsEmpty() {
return ""
}
if a.User == "postmaster" && a.Host == "" {
return "postmaster"
}
if a.Quoted {
var sb bytes.Buffer
sb.WriteByte('"')
Expand Down
11 changes: 10 additions & 1 deletion mail/envelope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,20 @@ func TestMimeHeaderDecodeNone(t *testing.T) {
}

}

func TestAddressPostmaster(t *testing.T) {
addr := &Address{User: "postmaster"}
str := addr.String()
if str != "postmaster" {
t.Error("it was not postmaster,", str)
}
}

func TestNewAddress(t *testing.T) {

addr, err := NewAddress("<hoop>")
if err == nil {
t.Error("there should be an error:", addr)
t.Error("there should be an error:", err)
}

addr, err = NewAddress(`Gogh Fir <[email protected]>`)
Expand Down

0 comments on commit 2a405ae

Please sign in to comment.