Next: , Previous: , Up: Top   [Contents][Index]


3 Matching Entire Messages

Two functions are provided to search for regular expressions within emails. They are declared as follows:

func pcre_match_message(number rx, number msg; string charset)
  returns string
func pcre_string_match_message(string regex, number msg; string charset)
  returns string

The message to search in is given by message descriptor, i.e. an integer number identifying it. This descriptor is returned by one of the following calls:

mailbox_get_message

See mailbox_get_message in Mailfromd Manual.

current_message

See current_message in Mailfromd Manual.

message_from_stream

See message_from_stream in Mailfromd Manual.

Message searching fuctions can be used to search in plain as well as in multipart (MIME) messages. When searching in a MIME message, it is descended recursively and each its part is searched individually.

On success (a match is found), these functions return a string describing where the match was found. For example, ‘1’ means that the plaintext message body matched, ‘1.2’ means second part of a multipart message, ‘1.2.3’ means third subpart of the second part of a multipart message, etc.

On error, an empty string is returned.

Only textual parts of a MIME message are considered. A textual part, for the matching purposes, is a part whose Content-Type header matches one the globbing patterns in the text mime type list. By default this list contains a single value: ‘text/*’.

More patterns can be added to text mime type list using the pcre_text_mime_add function. It takes variable number of arguments, e.g.:

pcre_text_time_add("application/x-json", "x-text/*")

Similarly, the function pcre_text_mime_del allows you to delete elements from this list. Note, that it treats its arguments literally, not as globbing patterns. For example, suppose the following call is done when the text mime type list contains two elements: ‘text/*’, and ‘*/x-sh’:

pcre_text_time_del('text/*')

This will remove only one item: ‘text/*’, but won’t touch ‘*/x-sh’ (which it would do, if it treated its argument as a globing pattern).

Finally, the function pcre_text_mime_init removes all entries from the list.


Next: , Previous: , Up: Top   [Contents][Index]