Skip to content

panic from msgwriter if building a mail.Msg from multipart EML #482

@mjentsch

Description

@mjentsch

Description

I have a case where prepared notifications (EML) are to be sent. Using the EMLToMsgFromString results in a panic: assignment to entry in nil map.

I forked to prepare a fix and saw that it is already fixed with 88f17e1 and the initializing of multiPartBoundary.

To Reproduce

package main

import (
	"log"

	"github.com/wneessen/go-mail"
)

const eml = `From: <[email protected]>
To: <[email protected]>
Subject: test
Importance: normal
X-Priority: 3
Content-Type: multipart/mixed;
 boundary=69529abbd38fadd1d8aea7092ec45071385e19584d9db4a46d5a365a78d1

--69529abbd38fadd1d8aea7092ec45071385e19584d9db4a46d5a365a78d1
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8

this is a test
--69529abbd38fadd1d8aea7092ec45071385e19584d9db4a46d5a365a78d1
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8

this is a test
--69529abbd38fadd1d8aea7092ec45071385e19584d9db4a46d5a365a78d1--
`

func main() {
	var (
		err error
		msg *mail.Msg
	)

	if msg, err = mail.EMLToMsgFromString(eml); err != nil {
		log.Fatal(err)
	}

	if err = msg.WriteToFile(`msg.eml`); err != nil {
		log.Fatal(err)
	}
}

Expected behaviour

The creation of a file containing EML.

Screenshots

No response

Attempted Fixes

The fix is already there and needs to be released.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions