jpoehls / gophermail

Simple mail package for Go
MIT License
76 stars 30 forks source link

v0 gopkg release doesn't generate messages properly #29

Open DanielOaks opened 8 years ago

DanielOaks commented 8 years ago

It looks like the v0 gopkg release recommended in the readme doesn't generate messages properly. It might be best to just suggest using the Github directly or possibly updating the gopkg v0 release instead?

Cool library by the way, thanks to you and the contributors for publishing it :)

DanielOaks commented 8 years ago

Oh, I think I might see what's going on. It's an intermittent issue so it doesn't always show up.

writeHeader looks like it isn't retrieving the headers in the correct order here, so it's outputting a message like the following:

 Mime-Version: 1.0
Content-Type: multipart/mixed;
 boundary=a796d952ceeb72f2d67d664a27d5e6671935ae240753bc5bac5b9ba290e3
To: <receiver@example.com>
From: <sender@example.com>
Subject: message subject here

--a796d952ceeb72f2d67d664a27d5e6671935ae240753bc5bac5b9ba290e3
Content-Type: multipart/alternative;
 boundary=fb81b69ff86c807cb14b35f7e154cecda8e9cff180e89feac42b0f97acc6

--fb81b69ff86c807cb14b35f7e154cecda8e9cff180e89feac42b0f97acc6
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Text message body here.
--fb81b69ff86c807cb14b35f7e154cecda8e9cff180e89feac42b0f97acc6--

--a796d952ceeb72f2d67d664a27d5e6671935ae240753bc5bac5b9ba290e3--

When this happens, it's retrieving the headers in this order:

HEADER key: Mime-Version
HEADER key: Content-Type
HEADER key: To
HEADER key: From
HEADER key: Subject
HEADER key: Content-Type

Which makes Google tell me "555 5.5.2 Syntax error."