Skip to content

DialAndSend in client fails with a panic for multipart emails #462

@vsfku

Description

@vsfku

Description

The problem is that a panic is returned when trying to send a multipart email with attachment.
Version v0.6.2 has the problem while version v0.5.2 is running fine and doesn't have the bug.

The bug can be reproduced with a simplified variant of the invoice.eml file which can be found in "go-mail/testdata
/invoice.eml".

I attached the file to reproduce.

To Reproduce

invoice.txt

The steps to reproduce are basically:

  1. Read the EML file with the mail client (either EMLToMsgFromFile or EMLToMsgFromString). Use attached invoice.txt
  2. Configure the mail client so email can be sent (authentication, smtp server)
  3. Try to send the email which originated from the EML file

Create a mail client

`
import (
"fmt"
"log"
"strings"
"github.com/wneessen/go-mail"
)
client, err := mail.NewClient(...)

`
Read the attached eml file

message, err := mail.EMLToMsgFromFile(emlMailPath)

Send the email

mail.DialAndSend(message)

Results in

panic: assignment to entry in nil map ¦
¦ ¦
¦ -> github.com/wneessen/go-mail.(*msgWriter).writeMsg ¦
¦ -> /home/runner/go/pkg/mod/github.com/wneessen/[email protected]/msgwriter.go:143 ¦
¦ ¦
¦ github.com/wneessen/go-mail.(*Msg).WriteTo ¦
¦ /home/runner/go/pkg/mod/github.com/wneessen/[email protected]/msg.go:2243 ¦
¦ github.com/wneessen/go-mail.(*Client).sendSingleMsg ¦
¦ /home/runner/go/pkg/mod/github.com/wneessen/[email protected]/client.go:1442 ¦
¦ github.com/wneessen/go-mail.(*Client).SendWithSMTPClient ¦
¦ /home/runner/go/pkg/mod/github.com/wneessen/[email protected]/client_120.go:56 ¦
¦ github.com/wneessen/go-mail.(*Client).DialAndSendWithContext ¦
¦ /home/runner/go/pkg/mod/github.com/wneessen/[email protected]/client.go:1179 ¦
¦ github.com/wneessen/go-mail.(*Client).DialAndSend ¦
¦ /home/runner/go/pkg/mod/github.com/wneessen/[email protected]/client.go:1152

Expected behaviour

To panic when sending multipart emails. Restore behavior of version v0.5.2

Screenshots

No response

Attempted Fixes

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingconfirmedduplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions