mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +01:00
Fix create header maps in case SetHeader or SetAddrHeader is called on an empty Msg type
This commit is contained in:
parent
5faa6dfbd6
commit
183fb347d6
1 changed files with 6 additions and 0 deletions
6
msg.go
6
msg.go
|
@ -181,6 +181,9 @@ func (m *Msg) Charset() string {
|
||||||
|
|
||||||
// SetHeader sets a generic header field of the Msg
|
// SetHeader sets a generic header field of the Msg
|
||||||
func (m *Msg) SetHeader(h Header, v ...string) {
|
func (m *Msg) SetHeader(h Header, v ...string) {
|
||||||
|
if m.genHeader == nil {
|
||||||
|
m.genHeader = make(map[Header][]string)
|
||||||
|
}
|
||||||
for i, hv := range v {
|
for i, hv := range v {
|
||||||
v[i] = m.encodeString(hv)
|
v[i] = m.encodeString(hv)
|
||||||
}
|
}
|
||||||
|
@ -189,6 +192,9 @@ func (m *Msg) SetHeader(h Header, v ...string) {
|
||||||
|
|
||||||
// SetAddrHeader sets an address related header field of the Msg
|
// SetAddrHeader sets an address related header field of the Msg
|
||||||
func (m *Msg) SetAddrHeader(h AddrHeader, v ...string) error {
|
func (m *Msg) SetAddrHeader(h AddrHeader, v ...string) error {
|
||||||
|
if m.addrHeader == nil {
|
||||||
|
m.addrHeader = make(map[AddrHeader][]*mail.Address)
|
||||||
|
}
|
||||||
var al []*mail.Address
|
var al []*mail.Address
|
||||||
for _, av := range v {
|
for _, av := range v {
|
||||||
a, err := mail.ParseAddress(av)
|
a, err := mail.ParseAddress(av)
|
||||||
|
|
Loading…
Reference in a new issue