Sending a Legacy Transactional Template Email over SMTP
Info
For customers who are unable to use the Web API v3, SMTP or v2 is an acceptable option.
Danger
The X-SMTPAPI does not support Dynamic Transactional Templates. For sending Dynamic Transactional Templates you need to use v3 Mail Send.
Before you create and send a legacy transactional template email over SMTP you need to do the following:
- Integrate with the SendGrid SMTP API
- Send a test email over SMTP
- Build an SMTP Email
- Create a Legacy Transactional Template
To send a legacy transactional template email over SMTP, test your connection, choose a code example for your language, enable the template, and set the body and subject tags.
Sending a test SMTP email with Telnet is one of the most basic tests you can do. This test checks the connection and helps you determine the most basic problems:
- Is the server up?
- Is there a firewall blocking communication?
- Does the mail server allow for relaying of a particular domain/email address?
- What SMTP commands does the mail server support?
- Does the server respond with the correct hostname?
- Does the connection work outside any third party software or APIs?
Info
Make sure that the version of the template you want to use is set to active by using:
- The Activate a transactional template version endpoint
/templates/{template_id}/versions/{version_id}/activate - Or by activating the template version in the UI
To use a legacy template when you send, configure the X-SMTPAPI header of an SMTP message:
- Enable the
templatesfilter - Set the
template_idto one of your legacy transactional templates
1{2"filters": {3"templates": {4"settings": {5"enable": 1,6"template_id": "5997fcf6-2b9f-484d-acd5-7e9a99f0dc1f"7}8}9}10}
You can use X-SMTPAPI substitution and section tags in your template's subject and body content, and they will be replaced with the values specified when you send the message.