Manitou-Mail Home

2. Built-in functions

Expressions may call built-in functions that implicitly refer to the message being filtered. Functions provide information about the messages, the context and meta-data, but they're not allowed to modify anything. On the other hand, filter actions may modify some message properties, such as the priority or certain header fields. In this case, functions that are called subsequently work on the modified data. Another way of expressing this is that the effects of filters will cascade onto the filters.

Table XI.2. Built-in filter functions

Function nameReturn typeArgumentsDescription
agenumber A time unit as a string, which must be one of "minutes", "hours" or "days". Return the time elapsed since the date and time indicated in the Date field of the message, as a number of minutes, hours or days depending on the argument. If the date field cannot be parsed, the result is null.
bodystringNoneReturn the entire body of the message.
ccstringNoneReturn a comma-separated list of addresses extracted from the Cc (carbon copy) field. If the Cc field is "John Doe" <john.doe@example.org>, the cc function will return john.doe@example.org (whereas header("Cc") would return the entire field).
conditionbooleanCondition nameEvaluate the named condition and return its result. The name refers to another filter entry.
datebooleanDate fieldReturn the date and time of the message in the local time zone. The possible arguments are the same than for the now() function.
date_utcbooleanDate fieldIdentical to the date() function, except that the date and time is expressed in UTC time instead of the local time zone.
fromstringNoneReturn the sender's address extracted from the From field. In the unlikely event that there are several addresses in this field, return a comma-separated list of these addresses.
headerstringField nameReturn the decoded value of the header field, or an empty string if the field is not found. The line is unfolded and non US-ASCII characters encoded with the RFC-2047 rules have been decoded and converted to unicode. Use rawheader() to access the non-decoded version.
headersstringNoneReturn the decoded value of the entire message header as one big string with consecutive fields separated by a newline character. The lines are unfolded and non US-ASCII characters encoded with the RFC-2047 rules have been decoded and converted to unicode. This function should be used only in the rare cases where it's not adequate to target a specific field with the header() function.
identitystringnoneReturn the email address from our identities that is associated with the message. For an outgoing message, that would normally be the address of the From field. For an incoming message, it is the mail address that is associated with the spool directory from wich the mailfile has been picked up. These associations are declared in manitou-mdx configuration file.
nowstringDate fieldReturn the current date and time in the local timezone. The possible arguments and corresponding return values are:
  • "hour": the current hour with 2 digits, "00".."23"
  • "minute": the current minute with 2 digits, "00".."59"
  • "second": the current second with 2 digits, "00".."59"
  • "day": the day of the month with 2 digits, "01".."31"
  • "month": the month with 2 digits, "01".."12"
  • "year": the year with 4 digits
  • "weekday": the index of the day in the week with 1 digit "0".."6" (0 being sunday)
  • "date": the current date expressed as YYYY-MM-DD
  • "time": the current time expressed as HH:MM:SS
The result of now() refers to the beginning of the filter evaluation, so that it doesn't change during the evaluation itself.
now_utcstringDate fieldThis is identical to now(),except that it returns the date in UTC time instead of the local timezone.
rawheaderstringField nameReturn the non-decoded value of the header field, possibly with quoted-printable and base64 contents as defined in RFC-2047 , or empty if the field is not found. The line is unfolded. Generally the headerfunction should be used instead.
rawheadersstringNoneReturn the non-decoded value of the entire message header as one big string with consecutive fields separated by a newline character, possibly with quoted-printable and base64 contents according to RFC2047. Generally the headersfunction should be used instead.
tostringNoneReturn a comma-separated list of addresses extracted from the To (recipient) field. If the To field is "John Doe" <john.doe@example.org>, the to function will return john.doe@example.org (whereas header("To") would return the entire field).