Customizing and Mass Mailing of a Newsletter

February 12, 2020
Cover

There are thousands of different tasks and challenges during the process of software architecture and development. Some of them are simple; others are much more complex. The trick of a good job is that no matter what the complexity of a current app or feature is — everything has to be wisely organized, structured, and thought out. Every single part.

Here’s the case of creating a highly customized system for compiling emails from the data available on CMS and preparing them for mass mailing. Our team developed the whole application, but let’s focus only on this part. I want to show in detail the sequence of actions that made up the whole process.

So, our newsletter contains text and images, and it is important to have the ability to choose the exact order of information in the letter.

What we already had on the platform:

  • Lists of recipients (the registered users of our CMS) who will receive letters.
  • Customizable ads.
  • Templates in which data from ads will be replaced.

frontend

The development process can be described in the following stages.

1. The whole software is developed with React. We used React DnD (drug and drop), on the basis of which we formed the logic for displaying these ads and the ordering logic.

2. After that, all the data (identifiers of these ads) goes to the back end.

3. The back end takes all the necessary information that is needed to be displayed in the letter — location, title, price (with implemented feature — it can be converted to the desired currency).

4. The data is substituted into the template, which consists of a header, body, and footer. The body has a place for a proper ad displaying (template inside a template). Thus, the algorithm inserts ads into the template and repeats the action as many times as many ads we need for a certain letter. The template is a simple HTML. 

5. There are prepared lists (groups) of recipients that can be based on any attribute that the administrator chooses. These lists can be combined at will. At this stage, we choose groups of recipients.

scheme

6. Next, we have a preview of the email (we see it the way users will see it in their email client). If everything is OK, we select the sending schedule (send now, later, or save as draft).

7. The front end sends a sending date to the back end, which sets a timeout. Then, back end it runs a method that takes the prepared content of the letter, a list of recipients (user identifiers), and sends it using our email service.

8. By pressing the “send” button, our email service starts working. Since the number of recipients can be large, all data is sent in batches (the list is divided and sent by chunks). Email service takes care of the logic of debouncing, checks whether we send to valid emails.

architecture

Fragment of the architecture

That’s it. The newsletter is sent, the goal is achieved. At the same time, the person who creates the newsletter doesn’t need to have any programming skills, not even HTML. The admin just chose the proper list of recipients and the ads from the list. All the work takes several minutes.