Integrating SendGrid’s SMTP API with CFMAIL

2019-06-05 01:06发布

问题:

I am using SendGrid’s SMTP API (not WEB API) and am considering sending an email using cfmail. If I use cfmail to send the email, and want to use the X-SMTPAPI header somewhere, do you think that cfmail is a place to do that? Please clarify.

回答1:

You would do this by adding a custom header, using the cfmailparam tag. As such:

<cfmailparam  
    name="X-SMTPAPI" 
    value="{\"category\":\"Cool Emails\"}">

In context of the cfmail tag it would be as follows.

<cfmail 
    from="you@example.com" 
    to="nick@sendgrid.com" 
    subject="I am using CF Mail to do this!"> 
<cfmailparam  
    name="X-SMTPAPI" 
    value="{\"category\":\"Cool Emails\"}">

Look at my awesome use of cfmail!
</cfmail>

More can be found in the Adobe Documentation