go-gomail / gomail

The best way to send emails in Go.
MIT License
4.32k stars 572 forks source link

When "Return-Path" header is set it appends to the from address #71

Closed leventogut closed 7 years ago

leventogut commented 7 years ago

When I try to set the return-path header (with setHeaders, setHeader, or setAddresHeader) for bounce handling gomail only appends the given address to the original from address.

This is wrong behaviour, it should overwrite would you be able to point where this code resides ?

I am going over the source code but could'n find yet.

"Return-Path": [ "\u003cabusehandler@abusehandler.com\u003e", "\u003fromaddress@example.com\u003e" ],

many thanks for the library as always

leventogut commented 7 years ago

I think the issue here is that we can not set email address of the "MAIL FROM bounce@bounce.com" ...., As the return-path is derived from that.

any idea how we can pass this ?

leventogut commented 7 years ago

Closing the issue , ignore If anyone has stuck with the issue: you need to set Sender header then MAIL FROM is set to that headers value.

send.go getFrom function:

func (m *Message) getFrom() (string, error) { from := m.header["Sender"] if len(from) == 0 { from = m.header["From"] if len(from) == 0 { return "", errors.New(gomail: invalid message, "From" field is absent) } }

return parseAddress(from[0])

}