Principal Engineer | Mentor
There are 0 item in the queue
The Mail Scheduler operates on an event-driven approach, leveraging TypeScript to manage tasks and email queues efficiently. Here's a breakdown of the workflow:
Start by defining your email configuration using a simple JavaScript object. For example:
const flowMap = {
testEmail: {
when: {
hours: 2,
},
subject: "Welcome To Gazar.dev",
body: "This is a test Email sent from Gazar.dev based on your request",
},
};
This configuration specifies that an email with the subject "Welcome To Gazar.dev" and the provided body will be sent to the recipient after 2 hours.
Enter your email and select the desired event (e.g., testEmail) in the input form above. This triggers the corresponding event, adding a task to the task queue with an execution time of 2 hours.
The task queue utilizes a priority queue ordering with the heap sort algorithm to manage tasks efficiently. Every minute, the system checks the queue to determine if it's time to execute a task. Once the scheduled time arrives, the task is dequeued and processed.
Upon task execution, the system retrieves the email details from the configuration and adds them to the email queue. The email queue operates on a first-in-first-out (FIFO) basis, ensuring that emails are sent in the order they were scheduled.
The Mail Scheduler integrates seamlessly with the Simple Email Service (SES) provided by Amazon Web Services (AWS) for email delivery. Once an email is dequeued from the email queue, it is sent using the SMTP protocol through AWS SES, ensuring reliable and secure delivery.
With the Mail Scheduler, automating your email sending tasks has never been easier. By leveraging TypeScript, task queues, and an event-driven approach, you can schedule emails to be sent at specific times without manual intervention. Whether you're sending reminders, notifications, or personalized messages, the Mail Scheduler streamlines the process and saves you time and effort. Try it out today and experience the convenience of automated email scheduling firsthand!
Source Code:
https://github.com/ehsangazar/gaz-express/tree/main/src/routes/mail-scheduler