Skip to content

multipart email is not properly formatted when using smtp driver #21

Open
@kaptinlin

Description

@kaptinlin

Describe the bug
When send smtp email with both html and plain text, the Content-Type is not properly set.

To Reproduce

cfg := mail.Config{
	URL:         "smtp.gmail.com",
	FromAddress: "[email protected]",
	FromName:    "Gopher",
	Password:    "my-password",
	Port:        587,
}

mailer, err := drivers.NewSMTP(cfg)
if err != nil {
	log.Fatalln(err)
}

tx := &mail.Transmission{
	Recipients: []string{"[email protected]"},
	Subject:    "Multipart Email Example",
	HTML:       "<h1>This is the HTML Section!</h1>",
	PlainText:  "Plain text email goes here!",
}

result, err := mailer.Send(tx)

Expected behavior

From: [email protected]
To: [email protected]
Subject: Multipart Email Example
Content-Type: multipart/alternative; boundary="boundary-string"

--your-boundary
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Plain text email goes here!

--boundary-string
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

<h1>This is the HTML Section!</h1>

--boundary-string--

There is a article for Multipart MIME Email Guide. And go-simple-email seems work well with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions