{"id":18099399,"url":"https://github.com/mrday2day/aws-email-queue_and_task-queue_server","last_synced_at":"2025-08-26T09:07:09.929Z","repository":{"id":260151474,"uuid":"863790610","full_name":"MrDay2Day/AWS-Email-Queue_and_Task-Queue_Server","owner":"MrDay2Day","description":"This server handles email queuing and delivery using AWS SES, and also supports task scheduling with expiration notifications. It allows you to manage email send rates, templates, and attachments. The task queue API stores tasks with expiration dates, notifying your server when tasks expire.","archived":false,"fork":false,"pushed_at":"2025-03-18T02:33:02.000Z","size":321,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-08T08:08:59.525Z","etag":null,"topics":["aws-ses","aws-ses-notification","bash","docker","javascript","jwt-tokens","mysql-database","nodejs-server","open-source","typescript"],"latest_commit_sha":null,"homepage":"https://day2dayja.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrDay2Day.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-26T23:25:12.000Z","updated_at":"2025-03-18T02:33:06.000Z","dependencies_parsed_at":"2024-12-03T23:24:08.957Z","dependency_job_id":"0f388e84-7912-4ec4-a0c9-2f5e7452b91a","html_url":"https://github.com/MrDay2Day/AWS-Email-Queue_and_Task-Queue_Server","commit_stats":null,"previous_names":["mrday2day/aws-email-queue_and_task-queue_server"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/MrDay2Day/AWS-Email-Queue_and_Task-Queue_Server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrDay2Day%2FAWS-Email-Queue_and_Task-Queue_Server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrDay2Day%2FAWS-Email-Queue_and_Task-Queue_Server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrDay2Day%2FAWS-Email-Queue_and_Task-Queue_Server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrDay2Day%2FAWS-Email-Queue_and_Task-Queue_Server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrDay2Day","download_url":"https://codeload.github.com/MrDay2Day/AWS-Email-Queue_and_Task-Queue_Server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrDay2Day%2FAWS-Email-Queue_and_Task-Queue_Server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272200571,"owners_count":24890816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-ses","aws-ses-notification","bash","docker","javascript","jwt-tokens","mysql-database","nodejs-server","open-source","typescript"],"created_at":"2024-10-31T21:08:31.973Z","updated_at":"2025-08-26T09:07:09.903Z","avatar_url":"https://github.com/MrDay2Day.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv style=\"max-width: 600px; margin-right: auto; margin-left: auto;\"\u003e\n\n![GitHub License](https://img.shields.io/github/license/MrDay2Day/AWS-Email-Queue_and_Task-Queue_Server) ![GitHub contributors](https://img.shields.io/github/contributors/MrDay2Day/AWS-Email-Queue_and_Task-Queue_Server)\n![GitHub last commit](https://img.shields.io/github/last-commit/MrDay2Day/AWS-Email-Queue_and_Task-Queue_Server)\n\n# Task Queue \u0026 AWS Email Queue Server\n\nTask Queue with Expiration and Notification API. This microservice allows you to queue tasks with an expiration date and time. It monitors these tasks and triggers a callback to your designated API once a task has expired, ensuring that your services are notified in real-time when deadlines are missed or tasks require follow-up. The expiration logic is fully customizable to meet your workflow needs, allowing seamless integration with your existing systems.\n\nCentralized Email Queue with `AWS-SES` Integration. This microservice enables centralized management of email queues across multiple services. It integrates with Amazon Web Services\" Simple Email Service (`AWS-SES`) to handle all email-sending operations for Transactional and Promotional emails. Features include the ability to configure send rates based on your `AWS-SES` account limits, upload and manage `HTML` templates, and send emails with attachments. This service optimizes email delivery performance and ensures compliance with your account\"s rate limits, providing a scalable solution for high-volume email dispatch.\n\nBoth components work together to streamline task management and email delivery, offering robust and efficient handling of time-sensitive tasks and communication across your services.\n\n# Table of Content\n\n1. [Setup](#setup)\n1. [Environment Variables](#environment-variables)\n1. [Development](#deployment)\n   - [ts-node-dev](#ts-node-dev)\n   - [node](#typescript---javascript)\n   - [docker-compose](#docker)\n1. [Deployment](#deployment)\n   - [ts-node](#ts-node-1)\n   - [node](#typescript---javascript-1)\n   - [docker-compose](#docker-1)\n1. [API Keys](#api-keys)\n   - [Create API Key](#create-api-key)\n   - [Delete API Key](#delete-api-key)\n1. [Email Queue](#email-queue)\n   - [Send an Email](#send-an-email)\n     - [Adding to Email Queue](#adding-to-email-queue)\n     - [Responses from Email Queue](#responses-from-email-queue)\n   - [Email Records](#email-records)\n   - [Email Status Notification Breakdown](#email-notification-status-breakdown)\n   - [Tracking Emails](#tracking-emails)\n1. [Task Queue](#api-keys)\n   - [Add Task to Queue](#adding-task-to-queue)\n   - [Remove Task from Queue](#remove-task-from-queue)\n   - [Notifications from Task Queue](#notifications-from-task-queue)\n\n# Setup\n\nYou can start the server via using `ts-node`, `ts-node-dev`, `node` - `Javascript` compiled from `TypeScript` with or wihtout `Docker` (which is recommened for the quickest deployment).\n\n**IMPORTANT ACTION**\n\n**Copy `.env.template` to `.env`.**\n\n```bash\ncp .env.template .env\n```\n\nthen by executing `generate_admin_api_key.sh` this will generate a new `ADMIN_API_KEY` and also 150 character `SALT` for your `JWT`.\n\n```bash\n./generate_admin_api_key.sh\n```\n\n# Environment Variables\n\n| Variable                   | Default Value              | Description                                                                           |\n| -------------------------- | -------------------------- | ------------------------------------------------------------------------------------- |\n| ADMIN_API_KEY              | -                          | This API Key is used to do admin actions.                                             |\n| PORT                       | 3852                       | Port for server.                                                                      |\n| TEST                       | y                          | This puts the Emailing functionality in test mode and will simulate sending an email. |\n| NODE_ENV                   | dev                        | Either 'dev' or 'production'.                                                         |\n| TEST                       | y                          | Simulate sending emails to AWS.                                                       |\n| NODE_VERSION               | node:22.6                  | Node Version for docker.                                                              |\n| APP_NAME                   | Day2Day Email/Queue Server | Application name.                                                                     |\n| APP_URL                    | -                          | The domain for the server eg: https://a.bcd.com                                       |\n| APP_CONTAINER_NAME         | d2d_email_queue            | Docker container name                                                                 |\n| MAX_UPLOAD_SIZE            | 25                         | Max upload size for server per request.                                               |\n| SALT                       | -                          | Secret SALT to create JWT.                                                            |\n| JWT_EXP_HRS                | 3                          | Expire time for JWT in hrs.                                                           |\n| AWS_REGION                 | -                          | AWS SMTP Settings.                                                                    |\n| AWS_ACCESS_KEY_ID          | -                          | AWS SMTP Settings.                                                                    |\n| AWS_SECRET_ACCESS_KEY      | -                          | AWS SMTP Settings.                                                                    |\n| AWS_SES_SEND_LIMIT_PER_SEC | 10                         | 10 emails pre second.                                                                 |\n| AWS_SES_QUEUE_WAIT_TIME    | 1000                       | Cool down period before next batch in ms.                                             |\n| AWS_CONFIG_SET_NAME        | email-status               | The default configuration set name for SES.                                           |\n| MYSQL_HOST                 | server-mysql               | Default for docker.                                                                   |\n| MYSQL_USER                 | root                       | Default for docker.                                                                   |\n| MYSQL_PASS                 | root_password              | Default for docker.                                                                   |\n| MYSQL_PORT                 | 3959                       | Default for docker.                                                                   |\n| MYSQL_DB                   | d2d_email_queue            | Default for docker.                                                                   |\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n# Development\n\n\u003cdiv style=\"padding-left: 30px; margin-right: auto; margin-left: auto;\"\u003e\n\n## ts-node-dev\n\nUsing your local system using:\n\n\u003cdiv style=\"padding-left: 30px; margin-right: auto; margin-left: auto;\"\u003e\n\n**Step 1** - Continuos integration\n\n```bash\nnpm ci\n```\n\n**Step 2** - This execute the server using `ts-nod-dev`\n\n```bash\nnpm run ts-dev\n```\n\n\u003c/div\u003e\n\n## Typescript -\u003e JavaScript\n\nUsing your local system compiling `TypeScript` in watch mode to `Javascript` and then listen for changes with `nodemon`:\n\n\u003cdiv style=\"padding-left: 30px; margin-right: auto; margin-left: auto;\"\u003e\n\n**Step 1** - Continuos integration\n\n```bash\nnpm ci\n```\n\n**Step 2** - This execute the server using `ts-nod-dev`\n\n```bash\nnpm run dev\n```\n\n---\n\nIf there are any issues with starting the development server try:\n\n```bash\nnpx tsc\n```\n\nthen:\n\n```bash\nnpn run dev\n```\n\n\u003c/div\u003e\n\n## Docker\n\nUsing your local system using:\n\n\u003cdiv style=\"padding-left: 30px; margin-right: auto; margin-left: auto;\"\u003e\n\nUsing `ts-node-dev`\n\n```bash\n./app.sh docker-dev\n```\n\nCompiling `TypeScript` in watch mode to `Javascript`\n\n```bash\n./app.sh docker-dev-node\n```\n\n\u003c/div\u003e\n\n\u003c/div\u003e\n\u003cbr/\u003e\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n# Deployment\n\nEnsure that `NODE_ENV` is commented out or blank.\n\n_NB: Docker deployment is recommended for deployment._\n\n\u003cdiv style=\"padding-left: 30px; margin-right: auto; margin-left: auto;\"\u003e\n\n## ts-node\n\nUsing your local system using:\n\n\u003cdiv style=\"padding-left: 30px; margin-right: auto; margin-left: auto;\"\u003e\n\n**Step 1** - Continuos integration\n\n```bash\nnpm ci\n```\n\n**Step 2** - This execute the server using `ts-nod-dev`\n\n```bash\nnpm run ts\n```\n\n\u003c/div\u003e\n\n## Typescript -\u003e JavaScript\n\nUsing `node` to execute compiled `Javascript` from `Typescript`\n\n\u003cdiv style=\"padding-left: 30px; margin-right: auto; margin-left: auto;\"\u003e\n\n**Step 1** - Continuos integration\n\n```bash\nnpm ci\n```\n\n**Step 2** - This execute the server using `ts-nod-dev`\n\n```bash\nnpm run start\n```\n\n---\n\nIf there are any issues with starting the development server try:\n\n```bash\nnpx tsc\n```\n\nthen:\n\n```bash\nnpn run start\n```\n\n\u003c/div\u003e\n\n## Docker\n\n\u003cdiv style=\"padding-left: 30px; margin-right: auto; margin-left: auto;\"\u003e\n\nThis container uses `ts-node` to run production.\n\n```bash\n./app.sh docker-prod\n```\n\n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n\u003c!--  --\u003e\n\n# API Keys\n\nAPI Keys are managed using the `ADMIN_API_KEY` as `Bearer` Token in the `Authorization` Header.\n\n\u003cdiv style=\"padding-left: 30px; margin-right: auto; margin-left: auto;\"\u003e\n\n## Create API Key\n\nSend a `POST` request to the Email/Queue Server\n\n`{{SERVER}}/server/api/create` `POST`\n\nRequired:\n\n| Field      | Description                                                                                            |\n| ---------- | ------------------------------------------------------------------------------------------------------ |\n| api_name   | Name of API Key must be unique                                                                         |\n| return_api | API return route for this API key                                                                      |\n| temporary  | `false` will disable duration of api_key                                                               |\n| duration   | How long the API key should last for. Max 10 years **NOTE:** _Only required if `temporary` is `true`._ |\n\n\u003cbr/\u003e\n\n**Request 1** - Without out expiry date.\n\n```json\n{\n  \"api_name\": \"task_tracker_api_1\",\n  \"return_api\": \"http://api.server.com/task-tracking-1\",\n  \"temporary\": false\n}\n```\n\n**Response 1**\n\n```json\n{\n  \"api_name\": \"task_tracker_api_1\",\n  \"api_key\": \"9RkN1-fI6hfMclMNX4_Q6YahWBc.rIoMlBnRP34cYE30X76r\",\n  \"return_api\": \"http://api.server.com/task-tracking-1\",\n  \"expire_date\": null,\n  \"valid\": true\n}\n```\n\n## --\n\n## --\n\n**Request 2** - With expiry date of 4 days\n\n```json\n{\n  \"api_name\": \"task_tracker_api_2\",\n  \"return_api\": \"http://api.server.com/task-tracking-2\",\n  \"temporary\": true,\n  \"duration\": \"4d\" // m=minutes | h=hours | d=days | M=months | y=years\n}\n```\n\n**Response 2**\n\n```json\n{\n  \"api_name\": \"task_tracker_api_2\",\n  \"api_key\": \"qA5Bz-rly3vMUccmHP_mLW25Xjf.SpXIflHVcg4RF5XJ8MTv\",\n  \"return_api\": \"http://api.server.com/task-tracking-2\",\n  \"expire_date\": \"2024-10-07T18:13:03.000Z\",\n  \"valid\": true\n}\n```\n\n## Delete API Key\n\nTo delete and API Key send a `POST` request with either `api_name` **or** `api_key` to the Email/Queue Server\n\n`{{SERVER}}/server/api/delete` `POST`\n\n| Field    | Description     |\n| -------- | --------------- |\n| api_name | Name of API Key |\n| api_key  | API key         |\n\n\u003cbr/\u003e\n\n**Request**\n\n```json\n{\n  \"api_name\": \"task_tracker_api_1\"\n}\n```\n\nor\n\n```json\n{\n  \"api_key\": \"9RkN1-fI6hfMclMNX4_Q6YahWBc.rIoMlBnRP34cYE30X76r\"\n}\n```\n\n**Response**\n\nIf the request is successful `valid` will be `true` else `false` with a error message `msg`.\n\n```JSON\n{\n    \"valid\": true\n}\n```\n\n## Verify Return Token\n\nThis is a `POST` request to verify the return `JWT` token to your server that is sent in the Authentication header to your server as a `Bearer Token`.\n\n`{{SERVER}}/server/api/verify` `POST`\n\n| Field | Description |\n| ----- | ----------- |\n| token | JWT Token   |\n\n\u003cbr/\u003e\n\n**Request**\n\n```json\n{\n  \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7ImFwaV9nZW5fY29kZSI6IjFHZ0RQWlMyRmNLblM4RC41MXRvWlhwRVZvLkxLNmJKVEsxIiwidXJsIjoiaHR0cDovLzE5Mi4xNjguMC4xMjA6NDA0Mi9iaWRzcXVhd2sifSwiaWF0IjoxNzMyNjM3MzE1LCJleHAiOjE3MzI2NDgxMTV9.hH32CCGVo-KO01Z2_TnP_tyXOsXWghjCCExLQjlgRlk\"\n}\n```\n\n**Response**\n\nIf the request and token is successful `valid` will be `true` else `false` with a error message `msg`.\n\n```JSON\n{\n    \"valid\": true\n}\n```\n\nor\n\n```JSON\n{\n    \"msg\": \"invalid signature\",\n    \"valid\": false,\n    \"code\": \"API065_00005\"\n}\n```\n\n\u003c/div\u003e\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n# Email Queue\n\nThe Email Queue uses AWS-SES to send raw emails _(Email HTML file)_ with attachments _(File Buffer)_.\n\n\u003cdiv style=\"padding-left: 30px; margin-right: auto; margin-left: auto;\"\u003e\n\n## Email Templates\n\nEmail Templates are managed using the `ADMIN_API_KEY` as `Bearer` Token in the `Authorization` Header.\n\nEmail Templates should be a single HTML file with templates variables between `{{-` `VARIABLE` `-}}`. This file will be stored on the server, max size `500kb`.\n\nExample:\n\n```html\n...\n\u003cdiv style=\"font-size: 14px; line-height: 140%; word-wrap: break-word;\"\u003e\n  \u003cp style=\"line-height: 140%;\"\u003eDear {{-NAME-}},\u003c/p\u003e\n  \u003cp style=\"line-height: 140%;\"\u003e \u003c/p\u003e\n  \u003cp style=\"line-height: 140%;\"\u003e\n    You account balance is ready for {{-BALANCE-}} a/c {{-ACCOUNT-}}. You\n    balance is due {{-DATE-}}. If you have any issues making your payment please\n    email us at {{-SUPPORT_EMAIL-}}.\n  \u003c/p\u003e\n  \u003cp style=\"line-height: 140%;\"\u003e \u003c/p\u003e\n  \u003cp style=\"line-height: 140%;\"\u003eThank you\u003c/p\u003e\n  \u003cp style=\"line-height: 140%;\"\u003eManagment.\u003c/p\u003e\n\u003c/div\u003e\n...\n```\n\n\u003cdiv style=\"padding-left: 30px; margin-right: auto; margin-left: auto;\"\u003e\n\n### Adding a template\n\nMake a `Form-data` `POST` request to the Email/Queue Server with just the file. The filename of the html file will also be the template name.\n\n`{{SERVER}}/server/email/add-template` `POST`\n\nEg: If the file name is `welcome-email.html` then the template name is `welcome-email`.\n\n| Key  | Type        | Value              |\n| ---- | ----------- | ------------------ |\n| html | file/buffer | welcome-email.html |\n\nWhat the server expects to see:\n\n```json\n{\n  \"fieldname\": \"html\",\n  \"originalname\": \"welcome-email.html\",\n  \"encoding\": \"7bit\",\n  \"mimetype\": \"text/html\",\n  \"buffer\": \u003cBuffer 3c 21 44 ... 8390 more bytes\u003e,\n  \"size\": 8440,\n}\n```\n\n### Viewing all templates\n\nYou are able to see all templates stored on your server by sending a `POST` request, because this server can be used as a microservice for multiple applications and services depending on your server configuration you will be able to store hundreds of templates.\n\n`{{SERVER}}/server/email/list-templates` `POST`\n\n| Variable | Description                                           |\n| -------- | ----------------------------------------------------- |\n| page     | Page number for pagination.                           |\n| limit    | How many records per page (min=5, max=50, default=5). |\n\n**Request**\n\n```JSON\n{\n    \"page\": 1,\n    \"limit\": 20\n}\n```\n\n**Response**\n\n```JSON\n{\n    \"valid\": true,\n    \"templates\": [\n        \"welcome-email.html\"\n    ],\n    \"count\": 1,\n    \"total_pages\": 1\n}\n```\n\n### Removing a template\n\nTo remove a template simply provide the template name in a `POST` request.\n\n`{{SERVER}}/server/email/remove-template` `POST`\n\n**Request**\n\n```JSON\n{\n    \"fileName\": \"welcome-email.html\"\n}\n```\n\n**Response**\n\n```JSON\n{\n    \"valid\": true\n}\n```\n\nor\n\n```JSON\n{\n    \"msg\": \"File does not exist\",\n    \"valid\": false,\n    \"code\": \"EML001_400022\"\n}\n```\n\n\u003c/div\u003e\n\n## Send an email\n\nEmails are sent as `From-data` by using the generated API Key as `Bearer` Token in the `Authorization` Header. `ADMIN_API_KEY` cannot send emails.\n\n**Attachment Allowed MIME Types**\n\nTo edit: `src/middleware/multer.ts`\n\n| Extension | File Type          | mimetype                                                                  |\n| --------- | ------------------ | ------------------------------------------------------------------------- |\n| .gif      | Image              | image/gif                                                                 |\n| .jpeg     | Image              | image/jpeg                                                                |\n| .png      | Image              | image/png                                                                 |\n| .jpg      | Image              | image/jpg                                                                 |\n| .csv      | CSV                | text/csv                                                                  |\n| .html     | Text               | text/html                                                                 |\n| .doc      | MS Word            | application/msword                                                        |\n| .docx     | MS Word            | application/vnd.openxmlformats-officedocument.wordprocessingml.document   |\n| .xls      | MS Excel           | application/vnd.ms-excel                                                  |\n| .xlam     | MS Excel           | application/vnd.ms-excel.addin.macroEnabled.12                            |\n| .xlsm     | MS Excel           | application/vnd.ms-excel.sheet.macroEnabled.12                            |\n| .xlsx     | MS Excel           | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet         |\n| .pdf      | PDF                | application/pdf                                                           |\n| .ppt      | MS PowerPoint      | application/vnd.ms-powerpoint                                             |\n| .pptx     | MS PowerPoint      | application/vnd.openxmlformats-officedocument.presentationml.presentation |\n| .mdb      | MS Access Database | application/vnd.ms-access                                                 |\n| .json     | JSON               | application/json                                                          |\n| .xml      | XML                | application/xml                                                           |\n\n\u003cdiv style=\"padding-left: 30px; margin-right: auto; margin-left: auto;\"\u003e\n\n### Adding to email queue\n\n`Form-data` fields required for adding an email to the email queue.\n\n`{{SERVER}}/server/email/add` `POST` `FORMDATA`\n\n| Key        | Type          | Required | Description                                                                                                                               |\n| ---------- | ------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------- |\n| shortName  | string d      | Yes      | Senders Name.                                                                                                                             |\n| email      | string        | Yes      | Recipient Email.                                                                                                                          |\n| type       | string        | Yes      | Email type - `TRANSACTIONAL` or `PROMOTIONAL` (Transactional emails will take priority and will be sent 60% fast than promotional emails) |\n| sendEmail  | string        | Yes      | The sending email.                                                                                                                        |\n| replyEmail | string        | Yes      | Email recipient can reply to.                                                                                                             |\n| subject    | string        | Yes      | The subject of the email.                                                                                                                 |\n| data       | string (JSON) | Yes      | Template data for email.                                                                                                                  |\n| text       | string        | Yes      | Template string that is sent in-place of the template.                                                                                    |\n| template   | string        | Yes      | Name of template eg: If template is \"test.html\" then type \"test\"                                                                          |\n| files      | file/buffer   | No       | file/buffer[ ] of files for attachment.                                                                                                   |\n\n**Response**\n\n```JSON\n{\n    \"queue_id\": \"UYdo9ZLyVGbEVjEHYDj0-ytWG8b-t94KfQ4kRyOW\",\n    \"valid\": true\n}\n```\n\n### Responses from email queue\n\nIf the email is sent or failed your server/service will be notified at the \"return_api\" that was set when creating your API Key.\n\nA `JWT` will be sent back as a `Bearer` token to your server/service ensure that your server/service has the same secret `SALT` to verify the token signature.\n\n## Email Records\n\nYou can retrieve email queue records to check the status of previously sent emails. Access to these records is restricted to the API_KEY used when making the original request.\n\nThere are two methods for fetching these records:\n\n- You can either retrieve a specific set of records (max 20 per request) using the queue_id provided when the request was made.\n- You can fetch previously sent emails ordered by the most recent date, with a maximum of 50 records per request, in a paginated format.\n\n\u003cdiv style=\"padding-left: 30px; margin-right: auto; margin-left: auto;\"\u003e\n\n### **Retrieving Email Record**\n\n**Method 1**\n\nRetrieving a specific set of records (max 20 per request) using the queue_id by send a `POST` request.\n\n`{{SERVER}}/server/email/fetch-specific-records` `POST`\n\n| Key       | Type      | Value                                  |\n| --------- | --------- | -------------------------------------- |\n| email_ids | string[ ] | `queue_id` from emails added to queue. |\n\n**Request**\n\n```json\n{\n  \"email_ids\": [\"StIiOwJiK0AaYybV97Hp-3R95ig-N62MgYcZCw8O\"]\n}\n```\n\n**Response**\n\n```json\n[\n  {\n    \"valid\": true,\n    \"result\": [\n      {\n        \"email_id\": \"IL2yFJifMdIj3h0FWUGh-Mr5v14-NjwRuHaUL1MC\",\n        \"email\": \"name@email.com\",\n        \"send_email\": \"email@company.com\",\n        \"subject\": \"Draft Email\",\n        \"data\": \"{\\\"NAME\\\":\\\"John Brown\\\",\\\"ACCOUNT\\\":238570023,\\\"BALANCE\\\":\\\"$345,600,00\\\",\\\"DATE\\\":\\\"Monday, November 4th, 2024\\\",\\\"SUPPORT_EMAIL\\\":\\\"support@company.com\\\"}\",\n        \"open\": false,\n        \"created_at\": \"2024-10-13T15:41:06.000Z\",\n        \"updated_at\": \"2024-10-13T15:41:08.000Z\",\n        \"attachments\": 1,\n        \"api_key\": \"xxxxx-xxxxxxxxxxxx_xxxxxxxx.1wiTebojwpv2w8WcYAzD\"\n      }\n    ]\n  },\n  ...\n]\n```\n\n**Method 2**\n\nRetrieving previously sent emails ordered by the most recent date, with a maximum of 50 records per request, in a paginated format.\n\n`{{SERVER}}/server/email/fetch-api-records` `POST`\n\n| Key    | Type   | Value                                       |\n| ------ | ------ | ------------------------------------------- |\n| page   | number | Page number                                 |\n| amount | number | Number of results to retrieve min 5 max 50. |\n\n**Request**\n\n```json\n{\n  \"page\": 1,\n  \"amount\": 20\n}\n```\n\n**Response**\n\n```json\n[\n  {\n    \"valid\": true,\n    \"result\": [\n      {\n        \"email_id\": \"IL2yFJifMdIj3h0FWUGh-Mr5v14-NjwRuHaUL1MC\",\n        \"email\": \"name@email.com\",\n        \"send_email\": \"email@company.com\",\n        \"subject\": \"Draft Email\",\n        \"data\": \"{\\\"NAME\\\":\\\"John Brown\\\",\\\"ACCOUNT\\\":238570023,\\\"BALANCE\\\":\\\"$345,600,00\\\",\\\"DATE\\\":\\\"Monday, November 4th, 2024\\\",\\\"SUPPORT_EMAIL\\\":\\\"support@company.com\\\"}\",\n        \"open\": false,\n        \"created_at\": \"2024-10-13T15:41:06.000Z\",\n        \"updated_at\": \"2024-10-13T15:41:08.000Z\",\n        \"attachments\": 1,\n        \"api_key\": \"xxxxx-xxxxxxxxxxxx_xxxxxxxx.1wiTebojwpv2w8WcYAzD\"\n      }\n    ]\n  },\n  ...\n]\n```\n\n\u003c/div\u003e\n\n## Email Notification Status Breakdown\n\n| Status     | Payload                                                 | Description                                            |\n| ---------- | ------------------------------------------------------- | ------------------------------------------------------ |\n| QUEUE      | {status, email_id, data: {email_data, aws_info}}        | Email queued to be sent.                               |\n| PROCESSING | {status, email_id, data: {email_data, aws_info}}        | Email is the process of being sent.                    |\n| SENT       | {status, email_id, data: {email_data, aws_data}}        | Email sent but not delivered.                          |\n| ERROR      | {status, email_id, data: {email_data, aws_info, error}} | Error sending email.                                   |\n| DELIVERED  | {status, email_id, data: {email_data, aws_data}}        | Email Delivered.                                       |\n| OPEN       | {status, email_id, data: {email_data}}                  | Email has been opened.                                 |\n| BOUNCE     | {status, email_id, data: {email_data, aws_data}}        | Email Bounced.                                         |\n| COMPLAINT  | {status, email_id, data: {email_data, aws_data}}        | Email has been reported. (This will affect reputation) |\n\n```Javascript\n{\n  \"status\": \"...\",\n  \"email_id\": \"...\",\n  \"type\":\"...\".\n  \"data\":{\n    \"email_data\": {\n      \"email\": \"...\",\n      \"send_email\": \"...\",\n      \"subject\": \"...\",\n      \"data\": {...},\n      \"open\": true,\n    },\n    \"aws_info\": {...}, // Optional:\n    \"aws_data\": {...}, // Optional\n    \"error\": {...}, // Optional\n  }\n}\n```\n\n## Tracking Emails\n\nTo track email delivery status with AWS Simple Email Service (SES) on your server, you can use Amazon SES Notifications (via SNS - Simple Notification Service) to receive events such as email delivery, bounces, complaints, and rejections. Here's how you can set this up step by step:\n\n**STEP 1 - Enable Notifications in Amazon SES**\n\nFirst, configure Amazon SES to send event notifications for your emails.\n\n1 - Set up an SNS Topic:\n\n- Go to the Amazon SNS console.\n- Create a new SNS Topic where SES will publish events (like delivery, bounce, or complaint notifications).\n- After creating the topic, copy the Topic ARN because you'll need it in the next step.\n- Set up SES to Publish Notifications:\n\n2 - Go to the Amazon SES console.\n\n- Create Configuration Sets (Ensure this is the same `AWS_CONFIG_SET_NAME`).\n- Under the configuration set, choose Event Destinations and add a new one.\n- For Destination Type, select SNS.\n- Choose the SNS topic you created and select which events (e.g., Delivery, Bounce, Complaint) you want SES to send to this SNS topic.\n- Attach this Configuration Set to the emails you send by specifying it in the SendEmail or SendRawEmail API call.\n\n**STEP 2 - Subscribe Your Server to the SNS Topic**\n\nOnce SES publishes the notifications to SNS, you'll need to subscribe your server (which will listen for delivery statuses) to the SNS topic.\n\nSubscribe an HTTPS Endpoint to the SNS Topic:\n\n- Go back to the Amazon SNS console.\n- Choose the SNS topic you created.\n- Click on Create Subscription.\n- In Protocol, select HTTPS.\n- In Endpoint, enter your server's URL (e.g., `https://{{SERVER}}/email-status`).\n- After creating the subscription, SNS will send a confirmation request to your server's URL that will automatically be verified.\n\n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n# Task Queue\n\nTask can only be added to queue using the generated API Key as `Bearer` Token in the `Authorization` Header. `ADMIN_API_KEY` cannot send emails.\n\nA `JWT` will be sent back as a `Bearer` token to your server/service ensure that your server/service has the same secret `SALT` to verify the token signature.\n\n\u003cdiv style=\"padding-left: 30px; margin-right: auto; margin-left: auto;\"\u003e\n\n## Adding task to queue\n\nTo add a task to the queue is simply done by sending a `POST` request with the following variables\n\n`{{SERVER}}/server/queue/add` `POST`\n\n| Variable   | Description                                     |\n| ---------- | ----------------------------------------------- |\n| data       | Object with key value pairs.                    |\n| expiryDate | A `timestamp` for expire date and time of task. |\n\n**Request**\n\n```JSON\n{\n    \"data\": {\n        \"hello\": \"world\",\n        \"foo\": \"bar\",\n        \"value\": 1234567890\n    },\n    \"expiryDate\": \"2024-10-01T20:44:48.858Z\"\n}\n```\n\n**Response**\n\n```JSON\n{\n    \"taskId\": \"328V32KoEOuy8zLs4pdP-RY8oh9-ep68NY786RsD\",\n    \"valid\": true\n}\n```\n\n## Remove task from queue\n\nTo remove a task to the queue is simply done by sending a `POST` request with the following variables\n\n`{{SERVER}}/server/queue/remove` `POST`\n\n| Variable | Description               |\n| -------- | ------------------------- |\n| queue_id | Queue ID for task queued. |\n\n**Request**\n\n```JSON\n{\n    \"queue_id\": \"328V32KoEOuy8zLs4pdP-RY8oh9-ep68NY786RsD\"\n}\n```\n\n**Response** - Success\n\n```JSON\n{\n    \"removed\": true,\n    \"valid\": true\n}\n```\n\n**Response** - Error\n\n```JSON\n{\n    \"removed\": false,\n    \"msg\": \"'taskId' does not exist.\",\n    \"valid\": false,\n    \"code\": \"QUE001_90012\"\n}\n```\n\n## Notifications from Task Queue\n\nWhen actions are triggered by the queue where a task has been added, manually removed or expired notification is sent to your server/service of the action this is sent to the corresponding `return_api` for the API Key that executed the task.\n\nA `JWT` will be sent back as a `Bearer` token to your server/service ensure that your server/service has the same secret `SALT` to verify the token signature.\n\nWhen a new task is added to the queue:\n\n```JSON\n{\n  \"queue_id\": \"qA5Bz-rly3vMUccmHP_mLW25Xjf.SpXIflHVcg4RF5XJ8MTv\",\n  \"expire_data\": \"2024-11-01T20:44:48.858Z\",\n  \"event\": \"ADD\",\n  \"data\": { \"hello\": \"world\", \"foo\": \"bar\", \"value\": 1234567890 }\n},\n```\n\nWhen a new task is manually removed from the queue:\n\n```JSON\n{\n  \"queue_id\": \"qA5Bz-rly3vMUccmHP_mLW25Xjf.SpXIflHVcg4RF5XJ8MTv\",\n  \"expire_data\": \"2024-11-01T20:44:48.858Z\",\n  \"event\": \"REMOVE\",\n  \"data\": { \"hello\": \"world\", \"foo\": \"bar\", \"value\": 1234567890 }\n},\n```\n\nWhen a new task has expired:\n\n```JSON\n{\n  \"queue_id\": \"qA5Bz-rly3vMUccmHP_mLW25Xjf.SpXIflHVcg4RF5XJ8MTv\",\n  \"expire_data\": \"2024-11-01T20:44:48.858Z\",\n  \"event\": \"EXPIRED\",\n  \"data\": { \"hello\": \"world\", \"foo\": \"bar\", \"value\": 1234567890 }\n},\n```\n\n\u003c/div\u003e\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrday2day%2Faws-email-queue_and_task-queue_server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrday2day%2Faws-email-queue_and_task-queue_server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrday2day%2Faws-email-queue_and_task-queue_server/lists"}