0% found this document useful (0 votes)
93 views4 pages

E-Mail Queue Module

The document describes an email queue module that handles email requirements in applications. An email manager process accepts parameters from calling applications, generates emails, and pushes them to a queue table. A background worker process then sends the emails from the queue independently without blocking the calling application. The module includes tables to store queued emails, worker processes, and raised alarms. It also describes components like the manager interface, worker process, and use of email transport plugins.

Uploaded by

Gowri Rajesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views4 pages

E-Mail Queue Module

The document describes an email queue module that handles email requirements in applications. An email manager process accepts parameters from calling applications, generates emails, and pushes them to a queue table. A background worker process then sends the emails from the queue independently without blocking the calling application. The module includes tables to store queued emails, worker processes, and raised alarms. It also describes components like the manager interface, worker process, and use of email transport plugins.

Uploaded by

Gowri Rajesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

E-mail queue module

E-mail queue module is an independent module to handle all the e-mailing requirements in the
application. E-mail queue is executed by an background worker process. The worker process is
not dependent on the host for scheduling or trigger of e-mail transport. The calling application
process is not required to wait for the e-mailing to be completed.

Components

E-mail Manager process:

- E-mail manager will the only interface from the application to the e-mailing module

- This will accept the required parameters from the application process, generate the e-mail and push
the email to the queue table.

- Trigger the worker process.


- This will include sub-modules/sub-processes for each application process, which needs to utilize the e-
mail functionality.

- The e-mail content will be generated based on the requesting process and request parameters.

- Each sub-process can have separate rules, which may add-on or override the requested parameters

- The e-mail content should be based on a configurable template

- e-mail address can be multiple comma separated

- Error handling - Check for valid e-mail address format, Avoid sending to duplicates e-mails address in
the same mail. On error update to queue table and generate an error log and alarm hook.

- If the calling process needs an attachment to be attached:


- The attachment path should be sent along with the request params
- If a pdf needs to be generated, generate the pdf in a separate process and update the attachment
path to the queue.
- Multiple attachments can be sent

- Additional cc, bcc rules can defined in the sub-process

Queue table

CREATE TABLE IF NOT EXISTS `email_queue` (


`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`queue_id` int(10) unsigned NOT NULL,
`process` varchar(10) NOT NULL,
`from_name` varchar(64) DEFAULT NULL,
`from_email` varchar(128) NOT NULL,
`to_email` varchar(128) NOT NULL,
`cc_email` varchar(128) DEFAULT NULL,
`bcc_email` varchar(128) DEFAULT NULL,
`subject` varchar(255) NOT NULL,
`message` text NOT NULL,
`attachment_qty` int(1) NULL DEFAULT '0',
`attachment_paths` varchar(128) DEFAULT NULL,
`attachment_id` varchar(128) DEFAULT NULL,
`max_attempts` tinyint(3) unsigned NOT NULL DEFAULT '3',
`attempts` tinyint(3) unsigned NOT NULL DEFAULT '0',
`success` tinyint(1) NOT NULL DEFAULT '0',
`date_published` datetime DEFAULT NULL,
`is_blocked` tinyint(1) NOT NULL DEFAULT '0',
`priority` tinyint(1) NOT NULL DEFAULT '0',
`date_scheduled` datetime DEFAULT NULL,
`last_attempt` datetime DEFAULT NULL,
`date_sent` datetime DEFAULT NULL,
`error_log` text DEFAULT NULL,
`email_gateway` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `queue_id` (`queue_id `)

) ENGINE=MyISAM DEFAULT CHARSET=utf8_general_ci;

E-mail Manager interface in admin:

- The e-mail manager interface will list the emails queued and status of the e-mail
- Columns - Process, to, status, date-time sent, attempts
- Actions View, block
- View displays the content of the send or queued email, with from, to, cc, bcc, subject,
attachment names, date added, date sent and status.
-

E-mail sender worker process

- The e-mail sender worker process should send the emails from the queue. This is continues
independent process.
- The activities of the worker process should be logged in process register table
- The active process can be determined from the last_attempt column in the register table
- The worker process should be active for a specified time limit only (configurable, set to 1
minute). This is to overcomet he php session time-out issue.
- Before the worker process is terminated it should trigger another worker process.
- On trigger the worker process should check that if there is any other active worker process.
Continue, if no other process is active.
- Retry sending e-mail on error response
- If more than 5 e-mail failed generate an error log file, send the log file to admin, update to
alarm_hook table
- Blocked e-mails should not be sent and logged to error log. Do not hook to alarm.
- High priority e-mails should be given preference

- Additional cc, bcc rules can defined in the worker process


-

E-mail process register table

CREATE TABLE IF NOT EXISTS `email_worker_process` (


`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`worker_id` varchar(10) NOT NULL,
`queue_id` varchar(10) NOT NULL,
`success` tinyint(1) NOT NULL DEFAULT '0',
`last_attempt` datetime DEFAULT NULL,
`date_sent` datetime DEFAULT NULL,
`error_log` text DEFAULT NULL,
`email_gateway` varchar(20) DEFAULT NULL,

PRIMARY KEY (`id`),


KEY `process_id` (`process_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8_general_ci;

Alarm Hook table

CREATE TABLE IF NOT EXISTS `alarm_hook` (


`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`alarm_id` varchar(10) NOT NULL,
`alarm_type` varchar(10) NOT NULL,
`queue_id` varchar(10) DEFAULT NULL,
`issue_date` datetime DEFAULT NULL,
`severity` varcharr(10) DEFAULT NULL,

`is_open` tinyint(1) NOT NULL DEFAULT '0',


`is_snooz` tinyint(1) DEFAULT NULL,
`snooz_seconds` int(3) DEFAULT NULL,
`error_log` text DEFAULT NULL,

PRIMARY KEY (`id`),


) ENGINE=MyISAM DEFAULT CHARSET=utf8_general_ci;

E-mail transport plugin

- Any e-mail transport agent / pluging can be used sendmail, yiimail. We are using yiimail.
- The transport agent should be flexibly configured in the worker process.

You might also like