Once user setup a mailbox, rtBiz Mailbox module will start reading mails from your mailbox and once it gets a parsed email, it will initiate an action with this email. And now, relevant module will hook into this action to perform any task with this email. Task can be anythin such as:

Create a new ticket from the email. (Helpdesk)

Create a new lead from the email. (CRM)

Add a new followup to existing ticket/lead (Helpdesk/CRM)

rtBiz uses Rt_Mailbox library class from rtLib. Following are the attirbutes/methods/classes that Rt_Mailbox exposes for use.

Classes

Rt_Mailbox : This class does the basic CRUD operations on UI for Mailboxes.

Adds an admin page for Mailbox

Performs DB update if required.

Initializes all the db model classes in use

Initializes WordPress crons for mail parsing & mail delivery.

Initializes other settings classes for Server configurations and mail parsing.

rt_parse_email_cron : This cron gets triggered every 5 minutes. It reads all the mailboxes that are registered with mailbox library. It parses all the unread mails and pass it on to relevant module for further tasks.

rt_send_email_cron : This cron gets triggered every minute. It is nothing but a dumb mail queue. It fetched all pending emails from the db queue table and delivers to the appropriate delivery system. After that it changes the email status to sent in the queue. If any error occurs while sending the email, then the status will be set to error.

Rt_Zend_Mail : This class is a wrapper class for operating upon emails from the mailbox. It uses ZendMail library on the base.

So you can see this variable named $module_name here. This is nothing but the slug name with which the module is registered in rtBiz.

It means at any single point, emails from one mailbox can be passed to only one module to read and process. That way we can maintain one-to-one relationship with mailbox and module to parse the emails.

With this action, module will receive a bunch of parameters that are necessary in parsing/processing an email.

$email_subject - Can be used as entity title

$html_body - Can go into entity description or followup content

$from_email - Person who sent the email

$mail_time - Time at which email was sent

$all_emails - Any additional emails from CC / BCC headers

$uploaded - Mail Attachments if there are any. (Inline attachments are handled here.)