Did you know that with JangoMail, you can specify a Custom ID for your transactional messages? This is possible with both the API and Relay service, and can help identify your messages in reporting.
Let's take a quick look into how to set this up.
Sending with the API
Specifying a Custom ID is easiest with the API. If you're already using the SendTransactionalEmail API method, there's a slight modification required to add a Custom ID to your messages. All you need to do is add the following to your Options parameter:
CustomID=<Your Custom Id>
So for instance, if you want to add a Custom ID of "abcd1234" to your message, you would include this:
CustomID=abcd1234
A full example would be:
OpenTrack=True,ClickTrack=True,CustomID=abcd1234
And that's the only change you need to make. After sending, you can go to your reporting page and view the Custom ID for that message:
Sending with the Relay
You can also specify a Custom ID when sending with our Relay service, but it's a little bit more difficult. In order to do this, you'll need to edit the message header before you send it to us, and you'll need to tell us what header key to look for.
First, let's add the header to JangoMail so we know what header to look for. To get to this setting, navigate to Settings -> Transactional Settings -> Relay -> Custom-ID header.
For this example, let's say our header is going to be "X-CustomID." It's good to prefix your header with an "X-" to make sure you don't accidentally use a header which is required by our system. "X-CustomID" is a good choice.
Now, you'll need to modify your message to include the "X-CustomID" header. This is going to be different based on how you're building your message. We'll look at a two examples.
Swaks
If you're running on a Linux based operating system, swaks is a great tool for doing quick SMTP tests. Using the following command, you can relay a message through JangoMail with a Custom ID of "abcd1234":
swaks -s express-relay.jangosmtp.net -au <username> -ap <password> -f <from address> -t <to address> --add-header "X-CustomID: abcd1234"
After running this, you would be able to see your message with the Custom ID in reporting.
.NET SmtpClient
Let's say you're building and sending your message using the .NET SmtpClient library. You could add a header like this:
SmtpClient sClient = new SmtpClient("express-relay.jangosmtp.net", 2525); MailAddress from = new MailAddress(""); MailAddress to = new MailAddress(""); MailMessage message = new MailMessage(from, to); message.Subject = ""; message.Body = ""; message.Headers.Add("X-CustomID", "abcd1234"); NetworkCredential nCred = new NetworkCredential("", ""); sClient.Credentials = nCred; try { sClient.Send(message); } catch (Exception ex) { // There was an error }
Comments
0 comments
Article is closed for comments.