Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sendgrid not sending text to new line

I am using sendgrid api with nodejs and for some reason the emails are sending but not adding new lines. I've used and also \n but no luck. Any idea what is wrong?

Here is the code I am using

var email = {
      to: '[email protected]',
      from: '[email protected]',
      subject: 'Membership',
      text: 'Please view in html',
      html: 'Hello there!,</br>\n\n' +
      'Please click on the following link, or paste this into your browser to complete the process:\n\n' +
      'Welcome and thanks for joining.\n\n' +
      '</br>Your details we have are\n\n' +
      '</br> Name: ' + user + '\n\n' + '</br> Telephone number: ' + number + '</br> email: ' + email + '</br>'
      };
like image 640
ServerSideSkittles Avatar asked Nov 06 '15 18:11

ServerSideSkittles


People also ask

Can you CC in SendGrid?

SendGrid supports the capability to send the single email to one or more recipients in the TO field plus one or more recipients in the CC or BCC fields (reference here: https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/personalizations.html).

What is SendGrid ne?

SendGrid is a cloud-based SMTP provider that allows you to send email without having to maintain email servers. SendGrid manages all of the technical details, from scaling the infrastructure to ISP outreach and reputation monitoring to whitelist services and real time analytics.

How do I send an HTML email in SendGrid?

Email template with HTML codeClick “Download Template,” and we'll send you a copy of the HTML code to your inbox. You can then copy/paste the code into your email design editor to import the template and tailor it to your brand and campaign.

Does SendGrid save email content?

We retain email message activity/metadata (such as opens and clicks) for 30 days. We store customer's aggregated sending stats and suppression lists (bounces, unsubscribes) and spam reports (which may contain content) indefinitely, and we store minimal random content samples for 61 days.


1 Answers

I assume your "Plain Content" setting is turn off in sendgrid account. To allow html tags to work you need to use triple curly braces

{{{TEMPLATE_VARIABLE}}}

It will parse html tag as html rather than plain text. If you'll use double curly braces

{{TEMPLATE_VARIABLE}}

it will consider any html tag as plain text only.

like image 56
Vipul Patil Avatar answered Oct 13 '22 02:10

Vipul Patil