Send E-Mails from RSS feeds with AWS SES
Are you struggling with keeping up with all the news, blog posts and announcements on your favorite topic? RSS feeds help you to keep track of all the content you are interested in. Corresponding apps to digest RSS news feeds like Feedly, Flipboard and others are a good way to centralize all the content of your interest in one place but require to be installed as Yet another app and to be used to consume the content. Besides that, they don’t have in-depth filtering on a per-feed basis on common attributes like publishing dates, titles and tags. Additionally, you do not have the possibility to send all the content as a nice summary in a well-structured HTML format as an E-Mail to your inbox, which you check on a regular basis anyways. Until now :-)
In the following article, you will learn one way how to setup a bespoke HTML E-Mail with all the content of your interest and send it to subscribed participants. The given example showcases the processing and preparation of different news, blog posts, security bulletins and announcements of the AWS Cloud.
In the upper diagram, you see the complete architecture of the solution in scope. The diagram depicts the deployment view and highlights the data flow between the user and the different AWS services in use.
The user experience starts with a simple HTML form, where everyone with access can enter an email address to receive the newsletter.
After the user has clicked on “Submit” the E-Mail Id will be processed by a backend made of API Gateway and Lambda and added to a SNS topic, which is acting as a central storage of the subscribers. The decision to use a SNS topic as a “database of subscribers” was made because of two simple reasons:
- AWS SNS Service brings the Confirmed Opt-In functionality out-of-the-box. SNS will send a confirmation request to any newly added E-mail Id and only after successful confirmation the subscriber is activated and will receive the newsletter.
- Similar to the previous point AWS SNS Service brings the “unsubscribe functionality” out-of-the-box. Every user will have their own “Unsubscribe” link in the personalized E-Mail body, so that an opt-out can be done anytime.
These two advantages of the AWS SNS services make it possible to design the newsletter solution in form of a self-service.
Going forward in the user flow, after the user has submitted an E-Mail Id and verified the ownership of it, the E-Mail Id will be marked as confirmed in the SNS topic and will be used for sending out the newsletter content. Looking at the actual E-Mail generation and sending part in the diagram, we see that a Lambda function will be triggered at a custom-chosen interval by an AWS Cloudwatch rule. This Lambda function will request and parse different RSS feeds with the Python feedparser module and render HTML content with Python jinja2 package.
From the cost perspective, the solution consumes a bare minimum which results in a spend below 1$ a month. Check out the source code at https://github.com/andrejmaya/aws-email-newsletter and deploy your own version of the AWS newsletter solution. You would need to have Python, pip, AWS SAM CLI and of course an AWS Account to deploy to. Enjoy!