1

I am trying to send a reset password link through the sendgrid email. My email template is like this

<html><head>
      <title>Reset Password</title>
      </style>
      <!--user entered Head Start--><link href="https://fonts.googleapis.com/css?family=Fira+Sans+Condensed&display=swap" rel="stylesheet"><style>
    body {font-family: 'Fira Sans Condensed', sans-serif;}
</style>
    </head>
    <body style="background-color:#9E9E9E;">
      <div style="padding:20px;border:1px solid #9E9E9E;background-color:white">
      <h1>Reset Password</h1>
      <hr>
      
      <p>Click the button below to reset your password.</p>
      <a href="" style="display:inline-block;padding:10px;background-color:#2196f3;color:white">RESET PASSWORD</a>
      <p>If you did not make this
      request, please ignore this email.</p>
      </div>
      <div>
      <p style="padding:20px;border:1px solid #9E9E9E;">Send by Information Systems.</p>
      <div>
    
  
</body></html>

And back-end code is like this

const msg = {
      to: 'someone@gmail.com',
      from: 'sender@example.org',
      templateId: 'xxxx',
      dynamic_template_data: {
        subject: 'Testing Templates',

      },
    };


    await sgMail.send(msg);

How do I pass a URL address to the template and attach that to the href attribute in the <a> tag?

ouflak
  • 2,458
  • 10
  • 44
  • 49
margherita pizza
  • 6,623
  • 23
  • 84
  • 152

1 Answers1

2

I think you are very close. Doing something like below should work

<a href="{{url}}" style="display:inline-block;padding:10px;background-color:#2196f3;color:white">RESET PASSWORD</a>

and then in your dynamic_template_data do

...
 dynamic_template_data: {
        subject: 'Testing Templates',
        url: 'https://somelink.com..'

      }
...
esdee
  • 29
  • 1
  • 5