Sign up for a SparkPost account and visit our Developer Hub for even more content.
Firstly ensure you have python3, pip and git.
Next, get the project. Install pipenv (--user option recommended, see this article) and this article for MacOS.
Once you have pipenv, you can use it to install the project dependencies.
git clone https://github.com/ZSamuels28/SparkPost-RSS-Program.git
cd SparkPost-RSS-Program
python3 -m pip install pipenv
pipenv install
Note: In the above commands, you may need to run pip3 instead of pip.
Input your SparkPost API Key into the sample.env file and rename the file variables.env. Note these are case sensitive:
SPARKPOST_HOST
The URL of the SparkPost API service you're using. Defaults to https://api.sparkpost.com.
SPARKPOST_API_KEY
API key on your SparkPost account, with Recipient Validation rights.
The variables.env file should look something like the following:
# .env
SPARKPOST_API_KEY=1234567890ABCDEFGHIJKLMNOPQRSTUVXYZ
SPARKPOST_HOST=https://api.sparkpost.com
NOTE: You must have templates and receipient lists created in SparkPost, if you do not have any, make sure they are created prior to using this program.
cd SparkPost-RSS-Program
pyenv shell
python SparkPost-RSS.py
You will see the SparkPost RSS Transmission program with the following inputs/options:
| Option | Description |
|---|---|
| Enter RSS URL: | Enter your RSS URL here to read the elements from. |
| Read RSS | Button to read the RSS URL elements. |
| How many RSS items to send? | Determines how many RSS records should be sent. |
| Enter Campaign ID | Campaign ID to be used with SparkPost. |
| Choose Template | Drop-down to select which template will be used to be sent. Note, this template will appear below and can be edited here as well. |
| Choose Recipient List | Drop-down to select the SparkPost recipient list to be sent to. |
| Filter Elements | Allows the user to filter for specific RSS elements in the feed |
| Left text box | When a template is selected, the HTML for that template will appear here. You can also edit this HTML and update it. |
| Right text box | When an RSS Feed is loeaded, a list of items will be shown. Clicking on those items will add them to the left text box. |
| Send | Sends the email. |
| Update Template | Updates the selected template HTML with the HTML in the textbox. Note, this has a confirmation dialog as well. |
| Close | Closes the program. |
See sample template below for usage:
<html>
<body>
{{ each items }}
<p><a href="{{ loop_var.link }}"> {{ loop_var.title }} </a></p>
<p>{{ loop_var.summary }}</p>
{{ end }}
</body>
</html>