I have recently created a template in my SendGrid account which I'd like to use in my php application.
I'm currently sending emails using that account, but I have to code the html right inside my app, which doesn't provide the flexibility I need.
I couldn't find a method in the API to select the template I want to use and to replace the variables....
Any idea?
Thanks
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.
It provides a cloud-based email delivery service and handle all the heavy lifting involved in sending messages and getting them delivered. We are going to use SendGrid API for sending emails. SendGrid-PHP library helps you in a quick SMTP setting to send emails through SendGrid using PHP.
After digging through GitHub I found this code snippet which works for me... I hope it helps you. To use templates in v3 here is the code:
$mail->setTemplateId("xxxxxxxxxxxxxxxxxxxx");
// Put your template ID in from the web console after you create a template
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With