System Variables And Commands


This file contains the message with variables and commands that will be sent back. It can be either a plain text message or you can include attachments, make html messages or simply anything.

Variables (Functions that return values):

%%From%% - whole From header of the message
%%From_Email%% - first email address from the From header
%%From_Alias%% - alias part of the first email address from the From header
%%From_Domain%% - domain part of the first email address from the From header
%%From_Name%% - name taken from the From header
%%To%% - whole To header of the message
%%To_Email%% - first email address from the To header
%%To_Alias%% - alias part of the first email address from the To header
%%To_Domain%% - domain part of the first email address from the To header
%%To_Name%% - name taken from the To header
%%Sender%% - sender of the message (whole content of MAIL FROM: command, even with < and >)
%%Sender_Email%% - email address of the sender (without < and >)
%%Sender_Alias%% - alias part of senders email address
%%Sender_Domain%% - domain part of senders email address
%%Auth_Email%% - email address of the authenticated user (without < and >), or empty if nobody authenticated
%%Auth_Username%% - username of the authenticated user (without < and >), or empty if nobody authenticated
%%vcard FIELD%% - vCard variable of message sender specified by FIELD.
Following algorithm is used to identify user whose vCard data should be used:
  • "From" header of the message is matched against local account
  • if no match found, SMTP Sender of the message is matched against local account
  • if no match found, user account used during SMTP authentication is used
  • if no SMTP authentication, %%vcard%% variables will be replaced by empty string
E.g. %%vcard FN%%, %%vcard TITLE%%
%%vcard FIELD:NUM%% - This is extended variant of the previous %%vcard option.
It is usable when the relevant field consist of multiple items. You can specify number of the item which corresponds to the versit 4.0 specification.
E.g. %%VCARD ADR:3%% (street), %%VCARD ADR:4%% (city)
%%vcard FIELD#ATTR~VAL%% - This is extended variant of the previous %%vcard option.
It is usable when the relevant field may appear more then once in the VCARD. You can specify attribute name and a value which will be searched in that attribute (fulltext).
E.g. %%VCARD TEL#TYPE~WORK%%, %%VCARD TEL#TYPE~HOME%%
%%vcard FIELD:NUM#ATTR~VAL%% - This is most advanced variant of the %%vcard options.
It combines both extended variants.
E.g. %%VCARD ADR:3#TYPE~WORK%% (stret of the work address), %%VCARD ADR:4#TYPE~HOME%% (city of the home address)
%%secure_connection%% - "1" or "0" - indicates if connection is secured (either via direct SSL, or using STARTTLS)
%%Recipient%% - list of all recipients delimited with semicolon ((whole content of RCPT TO: commands, even with < and >)
%%Forward_recipients Host#port%% - list of all recipients prepared for relay to given Host, delimited with semicolon
Eg: %%Forward_recipients mail.domain.com%% -> @mail.domain.com:r1@xx.com;@mail.domain.com:r2@xy.com;
%%Forward_local_recipients Host#port%% - similar to %%Forward_recipients%% , but only local accounts are added to the output
%%Forward_domain_recipients Host#port;domain1;domain2%% - similar to %%Forward_recipients%% , but only recipients from given domains are added to the output
%%BCC_Recipient%% - list of recipients not present in TO: or Cc: headers, delimited with semicolon ( even with < and >). If this variable is used in content filter during "copy incoming/outgoing mail" operation (using the "apply content filter" option), original email recipients are used, not the recipients where the message is being copied to.
%%Current_Recipient%% - email address of the current recipient - the address of the account being processed
 
%%regex_current_recipient RegexPattern ## ReplacePattern ## ErrorOutput %% - email address of the current recipient post processed with regular expression
RegexPattern - Regular expresion used for extracting data from the email addres.
e.g.: ^(.*)@(.*)$
ReplacePattern - Pattern for the data extraction.
e.g.: $1
e.g.: $1_$2
ErrorOutput - String which will be retuned in case of some evaluation failure (e.g. RegEx does not match)

Example: %%regex_current_recipient ^(.*)@(.*)$##$2##notfound%%
When recipient is mark@x1solar.com, then:
The regular expression ^(.*)@(.*)$ matches with $1= mark and $2=x1solar.com
Pattern $2 means that x1solar.com will be returned
 
%%sql_process_current_recipient QueryInputRegex ## QueryInputReplace ## QuerySQLPattern ## DBConnectionString ## ResultPatternReplace ## ErrorOutput %% - email address of the current recipient post processed with regular expression and SQL query
QueryInputRegex - Regular expresion used for extracting data from the email addres so that it can be used in the SQL query.
e.g. ^(.*)@(.*)$
QueryInputReplace - Pattern for the data extraction.
e.g.: $1
e.g.: $1_$2
QuerySQLPattern - Pattern for the SQl query. %s in the pattern will be replaced by the value extracted by the regular expression
e.g.: SELECT name FROM Mytable Where alias='%s'
DBConnectionString - Connection string to the database in classical form
ResultPatternReplace - Regular expression from QueryInputRegex will be also used to form pattern of output value. Choose patterns that will produce %s, which will be later replaced by the result of the SQl query.
e.g. $1%s$2
ErrorOutput - Specify string which will be retuned in case of some evaluation failure (e.g. Db not accessible)

Example: %%sql_process_current_recipient ^(.*)@(.*)$##$2##SELECT remote_domain FROM DomainBoss WHERE domain='%s'##C:\data.db;karl;~#2hIUUAA==;;7;3##$1@%s%%
When recipient is mark@x1solar.com, then:
The regular expression ^(.*)@(.*)$ matches with $1= mark and $2=x1solar.com
Pattern $2 means that x1solar.com will be used as a param for the query
The performed query will be : SELECT remote_domain FROM DomainBoss WHERE domain='x1solar.com' (let's say it returns anotherdomain.com)
Pattern $1@%s will get mark@%s, then %s will be replaced by anotherdomain.com.
As a result, mark@anotherdomain.com will be returned
 
%%Recipient_Email%% - email address of first recipient of the message
%%Recipient_Alias%% - alias part of email address of first recipient of the message
%%Recipient_Domain%% - domain part of email address of first recipient of the message
%%Extension%% - Extension of the recipient email address containing the extension separator
%%ExtensionNoSep%% - Extension of the recipient email address without separator
%%Subject%% - Subject of the message
%%Message-ID%% - Message-ID of the message (even with < and >)
%%Date%% - current date
%%Time%% - current time
%%Header%% - all headers of the message
%%Body%% - body of the message in plain text
%%Body MaxSize%% - body of the message in plain text limited to MaxSize
%%Body_HTML%% - body of the message in HTML (if any)
%%Body_HTML MaxSize%% - body of the message in HTML limited to MaxSize (if any)
%%Size%% - size of the message in kB
%%IP%% - IP address of the sender
%%PORT%% - port of the sender
%%Local_IP%% - Active local IP address
%%Local_PORT%% - Active local port
%%UniqueID%% - Unique ID string (md5 random hash)
%%RFC822_Date%% - current date and time in RFC822 format, based on server time and GMT offset
%%RFC822_Date Num%% - date and time Num seconds in the future in RFC822 format, based on server time and GMT offset
Eg: %%RFC822_Date 60%%
%%AttachmentNames%% - names of the attachments delimited with semicolon
Use rarely. Requires a high CPU usage and processing time.
%%Header HeaderItem%% - particular message header.
Eg: %%Header X-Mailer%%
%%Include FileName%% - includes content of the filename. Please see the example at the end of this file
%%Include_Base64 FileName%% - includes filename in Base64 encoding. Please see the example at the end of this file
%%MessageFile%% - filename (.tmp or .imap file) storing actual content of the message
%%Copy HeaderItem Position Length%% - copy Length characters of HeaderItem from Position
%%Delete HeaderItem Position Length%% - delete Length characters of HeaderItem from Position
%%FormatDateTime Format%% - formated date of the message
Eg: Today is %%FormatDateTime yyyy-mm-dd hh:nn:ss%%
%%StrReplace Variable OldString NewString CaseSensitive%% - Returns another Variable with some OldString replaced with NewString.
Eg: when %%Recipient%% returns a@t.com , then %%StrReplace Recipient @t @q 0%% returns a@q.com
%%CharEscape Variable EscapeChar CharsToEscape%% - Returns escaped value of another Variable. Each character from CharsToEscape is prefixed by EscapeChar
Eg: when %%Recipient%% returns a@t.com , then %%CharEscape Recipient \ @%% returns a\@t.com
%%VirusName%% - name of the viruses delimited with semicolon
%%VirusDBDate%% - last update date of the database for AntiVirus engine
%%SpamProbability%% - SPAM probability returned from Bayesian filter
%%SpamPercentage%% - SPAM probability returned from Bayesian filter in percent units
%%SpamHits%% - Total message SPAM score
%%SpamScore%% - The same as %%SpamHits%%
%%SpamReason%% - reason why message has been marked as spam
%%MailboxPath%% - Path to user mailbox relative to mail directory
%%Mailbox%% - Name of user mailbox directory
%%Alias%% - Primary alias of user
%%PhoneAlias%% - Phone alias of user
%%InstallPath%% - Path to server installation directory
%%Temp%% - Contains last fetched line from client, suitable for Milter filters
%%Exec CommandPath%% - Variable is replaced by string returned by executable at CommandPath
 

Commands:


(These special extended variable commands work only for Auto Responders and Content Filter message actions)
$$SetSender Sender$$ - set sender of the message to some value
$$SetRecipient Recipient$$ - set recipient of the message to some value
$$SetActualTo To$$ - set To header to some value
$$SetActualFrom From$$ - set From header to some value
$$SetSubject Subject$$ - set Subject to some value
$$SetReplyTo ReplyTo$$ - set ReplyTo header to some value
$$SetMessageID MessageID$$ - set MessageID to some value
$$SetPartBoundary PartBoundary$$ - set Boundary (used for messages with attachment, see the example at the end of this file)
$$SetContentType ContentType$$ - set Content Type of particular Boundary (see the example at the end of this file)
$$SetHeader Header$$ - set some header to some value
$$Exec CommandPath$$ - Application at CommandPath is executed (not available in auto responder)
 

Example #1 (Simple Auto Responder):

Hello, I received your your message at %%Time%% on the %%Date%% and the size was %%Size%% kB.
 

Example #2 Advanced Auto Responder With An Attachment:

Works only for Content Filters with "Send message" or "Reply with message" actions
(not for normal AutoResponders, because of security)
$$SetSubject Message Subject: %%Subject%%$$
$$SetPartBoundary --BoundaryXX$$
----BoundaryXX
Content-Type: text/plain

This is the text part of the message. The following part contains an attachment image.

----BoundaryXX
Content-Type: application/octet-stream; name="image.gif"
Content-Transfer-Encoding: base64

%%Include_Base64 c:\temp\image.gif%%

----BoundaryXX
 

Example #3 (Message containing only attachment):

Works for Content filters only
$$SetHeader Content-Type: application/octet-stream; name="filename.ext"$$$$SetHeader Content-Transfer-Encoding: base64$$
%%Include_Base64 d:\daily.txt%%
 

Example #4 (Virus Warning):

Warning: Virus '%%VirusName%%' detected. Message was rejected.
Message's header:
%%Header%%
 

Example #5 Advanced Auto Responder with Embedded Image:

Works only for Content Filters with "Send message" or "Reply with message" actions
(not for normal AutoResponders, because of security)
$$SetSubject Message Subject: %%Subject%%$$
$$SetPartBoundary b1_6b8b8572a3c9723a4ccf208d838b6d1d$$
--b1_6b8b8572a3c9723a4ccf208d838b6d1d
Content-Type: multipart/alternative; boundary="b2_6b8b8572a3c9723a4ccf208d838b6d1d"

--b2_6b8b8572a3c9723a4ccf208d838b6d1d
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

--b2_6b8b8572a3c9723a4ccf208d838b6d1d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<head><title></title></head>
<body><div class=3D"iw_mail" dir=3D"ltr"> <img src=3D"cid:15519543692b=
09459f7z97790651" border=3D"0"><div class=3D"signature"></div </div><=
/body>                                            

--b2_6b8b8572a3c9723a4ccf208d838b6d1d--
--b1_6b8b8572a3c9723a4ccf208d838b6d1d
Content-Type: image/png; name="img.png"; charset="UTF-8";
Content-Transfer-Encoding: base64
Content-ID: <<15519543692b09459f7z97790651>
Content-Disposition: inline; filename="img.png"

%%Include_Base64 c:\temp\image.png%%

--b1_6b8b8572a3c9723a4ccf208d838b6d1d--