authboss
authboss copied to clipboard
authboss mailer removes newlines in text email bodies
Sending text down using a TextBody will have all newlines be removed whether the TextBody uses \n or \r\n in them when the user reads the email in their client.
(Having an HTMLBody that renders instead hides this problem, so you've got to do some work to get this to occur.)
There supposedly is code in smtpMailer to handle this but it does not seem to work correctly.
I think the mime and strings.Replace is confusing the process. If I delete all of the boundary stuff, and just plop the body in with
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
{{.TextBody}}
and do the strings.Replace on the template string (not the output from the template), everything seems to work correctly.
By "work correctly", I mean "shows up in an email client like Gmail properly rendered".
Hm. Interesting. More work to figure out. Again, will try to correct this in v2 and then backport (will also backport the other fix since that code is pretty much unchanged).
Where is this v2 code? I keep hearing about it but I'm not sure where to look for it.
Also, I think the fix is probably to use the mime libraries (ala mailyak's use) but I've not had a change to confirm.
https://github.com/volatiletech/authboss/tree/vcrazy
The awful branch name is because I tried something insane off the original dev branch, and I liked how that spike turned out I kept working on it and just failed to push it to a meaningful branch name. Let me know if you have any questions, I'd love to get another pair of eyes on it so I can address any potential problems without having to v3 immediately after v2 :)
Wasn't able to reproduce this unfortunately. Any other hints on how to do it? You could try out the tests yourself that I wrote: https://github.com/volatiletech/authboss/blob/vcrazy/defaults/smtp_mailer_test.go#L19
Using my gmail creds in the JSON file, it sent me 3 e-mails that all looked normal (newlines where they were expected). One text only, one html only, and one had both text and html.