Black Obama
Black Obama

Reputation: 103

Mail with html content shows break lines or ignores newlines

I am sending mail to users via mandrill and I using both smtp and mandrill api to send. Content of the mail is rendered go template (.tpl) When I put template like

Hi {{.name}},
<br/>
This is support.  
<br/>

it sends via mandrill api ok, but
is visible when I send via smtp, when use template like ( <br/> replaced with \n)

Hi {{.name}},

This is support.  

mandrill ignores that and shows everything in one line but smtp shows ok newlines. What is a solution for this ?

I am rendering template like

frame, err := template.New("foo").Parse( *templateString )
if err != nil {
    return nil, err
}
var doc bytes.Buffer
frame.Execute( &doc, *parameters )
temp := doc.String()

Upvotes: 0

Views: 1347

Answers (1)

guregu
guregu

Reputation: 176

Are you sending the mail as HTML? If so, you can wrap everything in the <pre> tag.

If you're not using HTML, setting this header should help: Mime-Type: text/plain

Also, try changing your newlines from \n to \r\n.

Upvotes: 2

Related Questions