Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
Emojis and Special Characters not rendering on Subject Header in Pug using Sendgrid

Please the issue is that any emoji or special character are not rendering on the subject header of the pug file. but working perfectly on the body. I compile both body and subject header differently using pug.

const compileHtmlFunction = pug.compileFile(
    path.join(__dirname, "../emails", templatePath, "html.pug")
  );



const getSubjectFunction = pug.compileFile(
    path.join(__dirname, "../emails", templatePath, "subject.pug")
  );

const payload = {


  DestinationEmail: to,
    SourceEmail: fromEmail ? `Switch By Sterling ${fromEmail}` : "Switch By Sterling team@switch-ng.com",
    Body: compileHtmlFunction(data),
    Subject: getSubjectFunction(data)
  };

"""""""""""""""""""""""""""""""html.pug

doctype html
include ../../layouts/header

div(style='display: none; max-height: 0; overflow: hidden;')
div(style='background-color: #ecedfa; line-height: 30px; padding-top:5px;')
  div(style='background-color: #ffffff; color: #484347;  margin: 0 auto; margin-top: 100px; max-width: 400px; padding: 20px;')
    div 
      center 
        img(src='https://res.cloudinary.com/dzkyrqr5e/image/upload/v1648553921/new-headers/password-reset_ait4kd.png' alt='' width='100%' height="100%" border='0' style='display: block; margin: 20px auto 20px auto;')
    p(style='margin: 0 0 5px 0;')
      | Hello #{first_name},
      br
      | You are receiving this email because there has been a password change request on your account.
      | If you initiated this request, please change your password by clicking the 'Change my password' button below. The link will expire after 10 minutes.
      br
      a(href=updatePasswordUrl) Change my password
      br
      | If you didn't request this, please ignore this email. Your password won't change until you access the link above and create a new one.
      br
      p(style='margin: 0') With 💜
      | Your friends at Switch

    include ../../layouts/footer_image

""""""""""""""""""""""""""""subject.pug

| Launch  💜
about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

The subject line of an email isn't rendered like an HTML file, so I don't think you want to escape the emoji in the subject.

Try changing your subject.pug file to:

| Launch ๐Ÿ’œ
about 4 years ago ยท Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!