I am trying to send emails using SendGrid email service using Dynamic Templates.
I am using SendGrid version 7.2.
"sendgrid/sendgrid": "^7.2",
Sending emails is working great and I am able to send emails successfully using the below code.
$this->mail->setTemplateId($templateId);
$response = $this->sendGrid->send($this->mail);
if ($response->statusCode() != 202) {
throw new \Exception("Failed to Send Email.");
}
The problem is sometimes the $templateId can be an invalid or belong to a deleted template.
I looked through the internet for hours and searched the documentation but couldn't find anything.
Is there a way to check if the email template exists before trying to send the email? Or maybe to retrieve a list of active email template ids from SendGrid?