Application Extension: incomingEmails.php
Submitted Mark, Apr 23 2010 10:13 AM | Last updated Mar 30 2012 07:41 PM
IP.Board supports receiving incoming EMails if the administrator has configured their server properly to do so.
If you want your application to be able to parse incoming Emails, you should create a "incomingEmails.php" file in your applications directory containing a class called "incomingEmails_(application)" (where "(application)" if your application key) with the two necessary methods as described below.
Once your application has an incomingEmails.php file, administrators can choose your application when setting up incoming Email rules. We recommend though that when installing your application, you add a query to automatically insert the necessary rules into the database.
process
This is called if your application matches a specific rule.
It receives six parameters:
The attachments parameter contains an associative array of attachment data.
Throughout the message body, tags like this indicate where attachments are placed:
The value will be an array to be inserted into the attachments table. You will need to set the attach_rel_module and attach_rel_id columns before inserting the data (or update after inserting).
handleUnrouted
If an incoming Email does not match any rules, this method will be called for all applications with an incomingEmails.php extension file. Your application can then decide if it wants to parse it anyway.
To avoid interference with other applications, we recommend you only parse Emails if sent to a specific address which the user should be able to configure which should be unique to your application.
It receives the same parameters as process and should return a boolean value indicating if your application accepted the Email. If you return true, no other application's handleUnrouted methods will be called.
If you want your application to be able to parse incoming Emails, you should create a "incomingEmails.php" file in your applications directory containing a class called "incomingEmails_(application)" (where "(application)" if your application key) with the two necessary methods as described below.
Once your application has an incomingEmails.php file, administrators can choose your application when setting up incoming Email rules. We recommend though that when installing your application, you add a query to automatically insert the necessary rules into the database.
process
This is called if your application matches a specific rule.
It receives six parameters:
- The first is the database object. At this stage, ipsRegistry is not set up, so you must use this object instead of ipsRegistry::DB().
- The second is the Email address the Email was sent to.
- The third is the Email address the Email was sent from.
- The fourth is the Email subject.
- The fifth is the Email message.
- The sixth contains information on any attachments to the Email (see below).
The attachments parameter contains an associative array of attachment data.
Throughout the message body, tags like this indicate where attachments are placed:
<!--ATTACHMENT:X-->Where "X" is the key of an element in the attachments parameter.
The value will be an array to be inserted into the attachments table. You will need to set the attach_rel_module and attach_rel_id columns before inserting the data (or update after inserting).
handleUnrouted
If an incoming Email does not match any rules, this method will be called for all applications with an incomingEmails.php extension file. Your application can then decide if it wants to parse it anyway.
To avoid interference with other applications, we recommend you only parse Emails if sent to a specific address which the user should be able to configure which should be unique to your application.
It receives the same parameters as process and should return a boolean value indicating if your application accepted the Email. If you return true, no other application's handleUnrouted methods will be called.












0 Comments
Do you have a tip, alternative approach, or extra information you want to share with the IPS community regarding this article? Did you spot an issue with this article, or is it missing useful information? Feel free to contribute by adding a comment!
Comments are not for questions or support. Such comments will be deleted.