Jump to content

Adding custom header values for Mailgun


This topic is 1225 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

Hi, we're sending SMTP emails through Mailgun to communicate with our event attendees. In order to group the emails appropriately, it looks like I have to tag them by attaching custom variables in the header. EmailSetHeader is straightforward enough, but is it possible to use it to attach, for example, X-Mailgun-Variables: {"my_message_id": 123}? I've linked the documentation I've found below but am still unclear on the right syntax. Would appreciate any direction.

 

https://documentation.mailgun.com/en/latest/user_manual.html#attaching-data-to-messages

X-Mailgun-Variables: {"first_name": "John", "last_name": "Smith"}
X-Mailgun-Variables: {"my_message_id": 123}

https://static.360works.com/plugins/EMAILPLUG/documentation.html#EmailSetHeader

EmailSetHeader( "reply-to" ; "[email protected]" )
EmailSetHeader( "bcc" ; "[email protected]" )
EmailSetHeader( "subject" ; "List of Example Headers" )

Edited by rayjay
Link to comment
Share on other sites

Hi rayjay,

You should be able to just add the name of the headers you want to add for the "header" parameter and then whatever that value needs to be for the "value" parameter. I ran a quick test where I supplied a made up header name "X-Test-header" with a value of "{test value}". Checking the headers of the delivered email, this shows up as X-Test-header: ⁨{test value} . So for your case your function call would look something like:

EmailSetHeader("X-Mailgun-Variables"; "{"first_name": "John", "last_name": "Smith"}")

You will have to escape those quotes within the {} so that the whole value is seen as a string by the script workspace

Link to comment
Share on other sites

  • Newbies

Thanks Ryan!

 

EDIT: Some examples I got working...

EmailSetHeader( "X-Mailgun-Variables"; "{" & Quote("CAMPAIGNID") & ":" & Quote("PFY20201216") & "}" )
SETS: X-Mailgun-Variables: {"CAMPAIGNID":"PFY20201216"}

EmailSetHeader( "X-Mailgun-Variables"; "{" & Quote("TARGETID") & ":" & EMAILS::UserID & "}" )
SETS: X-Mailgun-Variables: {"TARGETID":154768904323}

 

Edited by rayjay
Link to comment
Share on other sites

This topic is 1225 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.