In practice, the email sender is one of the most complex pieces of our system. I have actually designed an email sender using a queue system to send a huge volume of emails (more than a billion a month) and that is one of the reasons why I am not covering it completely: because it's really very complex.
However, for the sake of an explanation and simplicity, I have designed a simple process diagram of the email sender. Have a look:
Allow me to explain how this works. Queuing is one of the core designs of a scalable distributed system. The queue provides your system with the distribution and communication between your processes.
In our design, I used the queue (message ordering could be your choice, I used First in First out (FIFO) to handle the vast amount of email messages; imagine the volume in the billions and you just can't do a query to a database for that every single time you want to shoot over some emails).
So, the producer here fetches the email records from...