simplemail/fromaddress.go

22 lines
344 B
Go
Raw Permalink Normal View History

2024-02-20 23:51:48 +00:00
package simplemail
import (
"encoding"
"github.com/emersion/go-message/mail"
2024-02-20 23:51:48 +00:00
)
type FromAddress struct {
*mail.Address
}
var _ encoding.TextUnmarshaler = &FromAddress{}
2024-02-20 23:51:48 +00:00
func (f *FromAddress) UnmarshalText(b []byte) error {
2024-09-21 16:20:19 +01:00
address, err := mail.ParseAddress(string(b))
2024-02-20 23:51:48 +00:00
if err != nil {
return err
}
f.Address = address
return nil
}