This document outlines common ways our customers use SparkPost for general integration. These integrations cover essential topics like “how do I send email?” and “how do I know what happened to the email?” If you are transitioning from Postfix, Sendmail, or Exim, this document should explain everything you need to know about the basics of sending and reporting on email. The rest of this document assumes you have an existing SparkPost account. If you don’t, go here to get one.
How do I send email?
SparkPost will accept mail for transfer in a couple of ways. By far, the most common is SMTP (Simple Mail Transfer Protocol) and SparkPost presents itself precisely as any other secure email agent on port 587. If you currently have generation or mail merge software that creates an email for delivery, SparkPost will accept it as a standard SMTP message and attempt to deliver it. You will need a system that with a valid TLS certificate that can generate SMTP messages and send them over port 587. Postfix, Sendmail, and Exim all have this capability natively.
You have a web server that generates a merged message for email delivery through Postfix.
· Adjust the web server’s generation software to send SMTP message to your assigned SparkPost server instead of the Postfix server
· Yes it really is that easy
You have some management code that needs to use the local server’s “Mail” function.
· If you are using Sendmail, edit the /etc/mail/sendmail.mc file to add a “smart-host” definition.
· If you are using Postfix, edit the /etc/postfix/transport file to add an smtp relay definition.
IE: * smtp:MySparkPostServer.com
· Make sure you enable TLS and set your outbound port to 587.
· Apply the changes and restart the local mail services
· Execute the management code as, and the mail will route to SparkPost for delivery
What about REST injection?
For customers who use HTTP(S) to transport data in their networks, converting a message to SMTP can be cumbersome. SparkPost has a comprehensive REST API that can accept a JSON template, list of recipients, and substitution data over HTTPS and then convert that into generated (merged) email to be sent to the world over standard SMTP. This is particularly helpful to off-load the generation work from web servers to the mail engine.
Your servers generate a newsletter to 50,000 recipients daily merging personal data then send each individually through Postfix.
· Create JSON objects for the recipients, substitution data, and content template.
· Use the REST API to POST the JSON objects to SparkPost’s Transmission API. Doing this offloads the generation process to SparkPost for faster delivery.
· You can even put the JSON in a file and use cURL:
curl -v -H "Content-Type: application/json" -X POST \
https://api.sparkpost.com/api/v1transmissions [email protected]/newsletter.json
How do I get delivery information?
SparkPost collects copious amounts of delivery information and makes that available to you in JSON format that can be “pushed” as a webhook or “pulled” with an API call. The data for a delivery looks something like this:
"subject":"Welcome Letter Template",
That is probably much more data than you are used to seeing in a Postfix log and it is already in a format that is easily consumable. It is relatively trivial to convert that JSON data to Postfix logging format if needed. Delivery, bounce, reject, spam_complaint, open, click, and delay data can be read the same way.
1) You usually export Postfix logs out to Excel so you can sort and analyze.
A) Execute a message_events API call and run the resulting JSON data through JSON2CSV.
2) You like to convert your Postfix logs to JSON, then pull them into a web service for reading and analysis.
A) Use the SparkPost metrics API to poll SparkPost for the data you need, and it is automatically exported as JSON
3) You have a separate process that tails and parses the logs in real-time and updates a separate recipient database.
A) SparkPost can provide a real-time webhook that can feed your process spam_complaintants and unsubscribes specifically for this purpose. Implementation is trivial.