I am using mailgun Templates with Go to send emails. However when the text in my template fields contain \n
no newline is added. My basic code looks like the following:
message := m.mg.NewMessage(sender, subject, body, recipient)
message.SetTemplate("my-template")
_ = message.AddTemplateVariable("myText", event.Text)
// ... Code for sending
I saw this answer about sending mail with newlines, however when I implement it like the following:
_ = message.AddTemplateVariable("myText", strings.ReplaceAll(event.Text, "\\n", "<br />"))
The email contains <br />
text in the body but no newlines.
I also tried adding the following field in the css of my template: white-space: pre-wrap;
but still there was no break. Thanks for any help with adding a newline to a Mailgun Template with Golang.