Navigation:  Accounts Menu > Account Settings > Auto Responders >

Creating Auto Response Scripts

Print this Topic Previous pageReturn to chapter overviewNext page

Auto response scripts are text files that define the messages that are returned as the result of an auto-response event. These scripts are constructed as plain ASCII text files ending with the "*.rsp" file extension. When an auto response script is triggered by an auto responder, the script file is processed and scanned for macros, which will then be replaced by actual data from the incoming message that triggered the response. Lines beginning with the "#" character are ignored and are used for comments.

There are several samples of scripts listed below, and there are several generic "*.rsp" files provided for you in MDaemon's \app\ folder.

Auto Response Script Macros

$HEADERS$

This macro will be replaced by all of the incoming message's headers. Text immediately preceding this macro will be duplicated at the start of each expanded line.

$HEADER:XX$

This macro will cause the value of the header specified in place of "xx" to be expanded in the message. For example:  If the incoming message has "TO: joe@example.com" then the $HEADER:TO$ macro will expand to "joe@example.com". If the original message has "SUBJECT: This is the subject" then the $HEADER:SUBJECT$ macro would be replaced with the text "This is the subject".

$BODY$

This macro will be replaced by the entire message body. In an attempt to preserve character sets for different languages, MDaemon will read the message body as binary data rather than pure text, thus allowing a  byte-for-byte copy of the message body.

$BODY-AS-TEXT$

Like the $BODY$ macro, this macro will be replaced by the entire message body, but as text rather than binary. Text immediately preceding this macro will be duplicated at the start of each expanded line. So, using ">>$BODY-AS-TEXT$" in a script would place each line of the original message into the generated message, but each line would begin with ">>". Text can also be added to the right of this macro.

$ATTACHMENTS$

This macro will be replaced by the entire list of all attached files extracted from the original message. Text immediately preceding this template variable will be duplicated at the start of each expanded line.

For example: FILE-LIST: $ATTACHMENTS$ would place each attachment file name into the generated message, preceded by the text string, "FILE-LIST:".

$ATTACHMENTCOUNT$

This macro will be replaced with an integer value equal to the number of attachments extracted from the original message.

$ATTACHMENT(X)$

This macro will be replaced with the attachment file name of the relative attachment number passed in the X parameter. If the value in X is greater than the total number of attached files then the entire variable is removed and replaced with nothing.

$SENDER$

This macro resolves to the full address contained in the incoming message's "From:" header.

$SENDERMAILBOX$

This macro resolves to the mailbox of the sender. The mailbox is the portion of the email address to the left of the "@" symbol.

$SENDERDOMAIN$

This macro resolves to the domain of the sender. This is the portion of the email address to the right of the "@" symbol.

$RECIPIENT$

This macro resolves to the full address of the message recipient.

$RECIPIENTMAILBOX$

This macro resolves to the mailbox of the message recipient.  The mailbox is the portion of the email address to the left of the "@" symbol.

$RECIPIENTDOMAIN$

This macro resolves to the domain of the message recipient.  The domain is the portion of the email address to the right of the "@" symbol.

$SUBJECT$

This macro resolves to the value of the "Subject:" header.

$MESSAGEID$

This macro resolves to the value of the "Message-ID" header.

$CONTENTTYPE$

This macro resolves to the value of the "Content-Type" header.

$PARTBOUNDARY$

This macro resolves to the value of the MIME "Part-Boundary" value found in the "Content-Type" header for multipart messages.

$DATESTAMP$

This macro expands to an RFC-2822 style date-time stamp line.

$ACTUALTO$

Some messages may contain an "ActualTo" field which generally represents the destination mailbox and host as it was entered by the original user prior to any reformatting or alias translation. This macro expands to that value.

$ACTUALFROM$

Some messages may contain an "ActualFrom" field which generally represents the origination mailbox and host prior to any reformatting or alias translation. This macro expands to that value.

$REPLYTO$

This macro resolves to the value found in the "ReplyTo" header.

$PRODUCTID$

This macro expands to the MDaemon version information string.

Header Replacement Macros

The macros listed below control the auto response message's headers.

%SetSender%

ex: %SetSender%=mailbox@host.org

Just for the purpose of the auto-response message, this macro resets the sender of the original message before constructing the auto-response message headers. Thus, this macro controls the auto response message's TO header. For example, if the sender of the original message were "pooky@domain.com" and recipient's auto responder used the %SetSender% macro to change it to "frank@example.com" then the auto-response message's TO header would be set to "frank@example.com."

%SetRecipient%

ex: %SetRecipient%=mailbox@host.org

Just for the purpose of the auto-response message, this macro resets the recipient of the original message before constructing the auto-response message headers. Thus, this macro controls the auto response message's FROM header. For example, if the recipient of the original message were "frank@example.com" and Frank's account had an auto responder using the %SetRecipient% macro to change it to "frank.thomas@example.com," then the auto-response message's FROM  header would be set to "frank.thomas@example.com."

%SetReplyTo%

ex: %SetReplyTo%=mailbox@host.org

Controls the value of the auto response message's ReplyTo header.

%SetActualTo%

ex: %SetActualTo%=mailbox@host.org

Sets who the "actual" recipient of the message will be.

%SetSubject%

ex: %SetSubject%=Subject Text

Replaces the value of the original message's subject.

%SetMessageId%

ex: %SetMessageId%=ID String

Changes the ID string of the message.

%SetPartBoundary%

ex: %SetPartBoundary%=Boundary String

Changes the part boundary.

%SetContentType%

ex: %SetContentType%=MIME type

Changes the content-type of the message to the declared value.

%SetAttachment%

ex: %SetAttachment%=filespec

Forces MDaemon to attach the specified file to the newly generated auto-response message.

Auto Response Script Samples

A simple auto response script, using several auto response script macros, might be called VACATION.RSP and look like this:

Greetings $SENDER$

You're message regarding '$SUBJECT$' won't be read by me because I'm on vacation. Hurray!!!

Yours truly,

$RECIPIENT$

You can also use some of the header replacement macros to expand this script and control the headers that will be generated when the auto response message is mailed back to $SENDER$:

Greetings $SENDER$

You're message regarding '$SUBJECT$' won't be read by me because I'm on vacation. Hurray!!!

Yours truly,

$RECIPIENT$

%SetSubject%=RE: $SUBJECT$

%SetAttachment%=c:\photos\me_on_vaction.jpg

Using that script the auto response message will have "RE: " added to the beginning of the subject and have the specified file attached.

The "%SetSubject%=RE: $SUBJECT$" line is handled like this:

1. The $SUBJECT$ portion is expanded and replaced by the original message's subject text. This makes the string equivalent to:

%SetSubject%=RE: Original Subject Text

2. MDaemon replaces the original subject, which it has stored in its internal buffers, with this newly calculated one. From that point forward, any use of "$SUBJECT$" in the script will return the new result.

Note the placement of the new macros - they are listed at the bottom of the response script. This is needed to avoid side effects. For example, if the %SetSubject% macro were placed before the $SUBJECT$ macro, which appears in the second line of the response script, the subject text would have already been changed by the time the $SUBJECT$ macro was expanded. Therefore, instead of replacing $SUBJECT$ with the content of the original message's "Subject:" header, it would be replaced with whatever you have set the value of %SetSubject% to be.

See: