PEP: Attachment Handling
Please consider switching to our new and improved hosting service: Islandhosting.com
For support call:     778-410-2454

PEP: Attachment Handling

Sometimes it is useful to be able to process individual attachments within a message. PEP allows you to delete attachments, extract them to your file space on the server, convert HTML attachments into plain text, and more.

Rules that manipulate attachments look like regular rules, but they work differently and are not documented on the other pages.

For processing attachments there are five special actions:

DEHTMLPART

This action converts an HTML attachment into plain text. It works by stripping out any HTML tags and converting certain HTML codes into their ASCII equivalents (eg: it would convert into a space).

DELETEPART

This action deletes an attachment and replaces it with a brief text message explaining what was deleted.

SAVEPART

This action decodes and saves an attachment into your file area under a file name you specify. The attachment is also deleted from the message.

COPYPART

This action is almost identical to SAVEPART, except that the attachment is not removed from the original message.

STOREPART

This action also decodes and saves an attachment, but instead of putting in your file area it puts it online and sends you an URL you can visit to view or download the attachment. You can optionally specify a password that will be required to view the attachment.

The actions above cannot be used when testing message headers, instead they can only be used when testing four special values that relate to attachments. These four special values are:

mimetype

This will be the MIME type for the attachment. Examples would include "text/html", "image/jpeg", and so on.

filename

This will be the filename of the attachment, if any.

headers

This value consists of ALL the MIME headers for a given attachment.

body

This value will contain the first 1 Kbytes (1024 bytes) of the body of the attachment.


You can use most of the comparison tests that you would use in a normal rule.

NOTE: these types of tests are always applied to ALL attachments in a message. PEP does not halt on a match, it simply performs the requested action and carries on.

Examples:

To convert all HTML attachments into plain text:
dehtmlpart if mimetype is "text/html"

To store all image attachments for online viewing later:

storepart if mimetype matches "image/*"

Same as above, but require "letmein" to be entered as a password when viewing:

storepart if mimetype matches "image/*" "letmein"

To save an attachment named "brochure.pdf" into your web directory:

savepart if filename is "brochure.pdf" to "www/brochure.pdf"