Editing Mail Templates
The mail template editor allows site administrators and list owners to customize administrative messages sent out by LISTSERV. When you first enter the template editor, the most frequently updated mail templates are listed alphabetically in a table. You can click on the column headers to change your sorting preferences. The case-insensitive filter row allows you to filter the templates that are displayed in the table. For example, if you want to see unsubscribe-related templates, type SIGNOFF in the filter box. To open a template for editing, simply click on its name. A new screen will open with a large text area, allowing you to make the desired changes to the template. Click "Update" to save the template. If you make a mistake, click "Revert" to restore the default version of the template.
Mail templates fall into three different types:
- Mail Templates: These templates control the content of email messages sent by LISTSERV. A mail template is a complete email message. Formatting commands are available, and substitutions that make sense in the context of the specific message are available.
- Message Templates: These templates supply text that will ultimately be shown to the user. These messages may be included in a mail template, or they may be returned to the web interface in response to commands. Limited formatting is available.
- Message Fragments: These templates are the lowest level of mail templates. Fragments are pieces of text produced by LISTSERV as parts of other messages or emails. Formatting commands are generally not available in fragments.
Template Categories
This pulldown menu allows you to narrow the templates shown in the table. For example, if you only want to see the most frequently modified templates or digest and index-related templates, choose the relevant option from the menu and click "Select". Use the Only Display Modified Templates option to narrow the list down to templates that have already been edited.
Search Templates
This field allows you to search the content of the mail templates. Simply type the desired query in the text box and click "Search".
Create New Template
To create a new web template, click on "Create New Template", enter the template name and a short description and click "Create". Note that the template name cannot contain spaces or special characters.
Template Style
LISTSERV can send out mail templates either in plain text or as HTML messages. Use the pulldown menu to select the template style of your choice and click "Select". To create new HTML template styles, go to the Newsletter Templates section. Whenever you create a new HTML newsletter template, the system also generates a simplified HTML mail template equivalent.
All frequently used mail templates support HTML. When you change the mail template style, the following mail templates are affected:
- WELCOME
- FAREWELL
- ADD1
- ADD2
- ADDMOD2
- ADDREQ1
- AUTODEL1
- AUTODEL2
- CHANGE1
- CONFIRM1
- CONFIRM2
- DELETE1
- INFO
- PROBE1
- PROBE2
- RENEW1
- RENEW2
- REQACK1
- SETINFO
- SIGNOFF1
- SIGNOFF2
- SIGNUP1
Note: As of LISTSERV 16.0, the old *WELCOME* and *FAREWELL* templates are obsolete. You can continue using any existing *WELCOME* and *FAREWELL* templates, but if you want to take advantage of the new HTML mail template styles, you should copy the existing content to the new WELCOME and FAREWELL templates.
If you have existing customized templates and would like to add HTML support to them, simply click "Enable HTML Template Styles" and LISTSERV will automatically insert the required code to the relevant templates.
Mail Template Commands and Conditions
The mail templates are not pure HTML code. They consist of HTML code interspersed with template commands and conditions. Commands and conditions in mail templates always begin with a . in the first character position of a line. Each command must be on a line by itself. The following list contains some examples of common commands and conditions:
.* |
Defines a comment line.
.* This is a comment and will be ignored |
.ASIS text |
Tells LISTSERV to leave the text immediately following the .ASIS directive alone, that is, don't convert < and > characters into HTML < and >. The .ASIS directive will only work on text it finds on the same physical line into which it is coded.
.ASIS Click <a href="http://some.host.com/some-doc.html">here</a>. |
.BB .ELSE .EB |
Creates a conditional block. The code found between the .BB and .ELSE is only displayed if the condition is true. The code found between the .ELSE and .EB is only displayed if the condition is false.
.BB &KWD(CONFIDENTIAL,1) = YES This list is confidential .ELSE This list is not confidential .EB |
.CC |
.CC OFF removes all "cc:" message recipients, if applicable. You can also add message recipients by specifying a series of email addresses after the .CC statement, for example .CC JOE@XYZ.EDU. |
.CE text |
Centers the text that you specify (just the text you typed on the same line as the .CE command). This can be useful to highlight the syntax of a command. |
.CS text |
Defines a character set for the template in question.
.CS ISO-8559-7 |
.FO OFF .FO ON |
Turns off formatting: one template line=one line in the final message. You can resume formatting with .FO ON or .FO RAGGed. |
.FO RAGGed |
Changes right-justified text formatting to left justified text formatting. You can resume right-justified formatting with .FO ON. |
.IM name |
Imbeds (inserts) another template into the current one. Only other mail templates may be imbedded. You cannot mix mail and web templates. |
.QU |
Ends processing of the current template as if you had reached the end, but without cancelling the message. |
.QUIF |
(QUIT IF) Ends processing of the current template without cancelling the message based on the result of a condition.
.QUIF &RC = 0
is equivalent to:
.BB &RC = 0 .QU .EB |
.QQ |
Cancels the message. LISTSERV stops reading the template and does not send anything. |
.RE OWNERS |
Adds a "Reply-To:" field pointing to the list owners in the header of the generated message. You can also use .RE POSTMASTER to direct replies to the LISTSERV administrator if this is more appropriate. |
.SE var text |
Defines or redefines a template variable. This is convenient for storing text that needs to be used several times. |
.SJ |
Sets the subject line for the message. This works differently depending on the type of template and is not available in message fragments.
- For mail templates, it overrides the subject line originally set for the template.
- For a message template, LISTSERV uses it only where it makes sense to do so. In message templates, it is generally used in conjunction with .SM.
|
.SM |
Sends a copy of the message via email. This is not available in message fragments. |
.TO |
Replaces the default recipients of a message with the one specified. |
Global Variables
&DATE |
Long-style date (04 Jan 2023). |
&HARDWARE |
The type of machine that LISTSERV is running on. |
&MBX(addr) |
Looks up the specified address in the LISTSERV signup file and displays "name <addr>" if a name is available, or just the original address otherwise.
This is typically used to give the name of the command originator or target, along with his email address: &MBX(&WHOM) or &MBX(&INVOKER). However, please note that &WHOM and &INVOKER are not always available in every template.
The "addr" parameter is always required; &MBX by itself is syntactically invalid. |
&MYHOST |
The Internet hostname of this LISTSERV site. |
&MYNAMES |
The substitution you will use most of the time when you need to refer to the LISTSERV command address. |
&MYNODE |
The Internet hostname of this LISTSERV site. |
&MYSELF |
The LISTSERV address, in the form of LISTSERV@XYZ.EDU. |
&OSNAME |
The full operating system name including the version number. |
&OSTYPE |
The operating system under which LISTSERV is running. |
&RELEASE |
The LISTSERV release number (17.5). |
&TIME |
hh:mm:ss |
&WEEKDAY |
Three-letter day of the week in English. |
List Variables
&DAYSEQ(n) |
Used to create FAQ templates with rotating topics. May also be used to create bottom banners with rotating text. |
&ISODATE |
Returns today's date in ISO format (yyyy-mm-dd). |
&KWD(kwd) |
Value of the specified keyword for the list. You don't need to specify the name of the list since this is implicit. Optionally, you can specify a second numeric argument to extract just one of the terms of a list header keyword.
For example, if the list header contains "Notebook= Yes,L1,Monthly,Private", &KWD(NOTEBOOK,4) has the value "Private". |
&LISTNAME |
The name of the list. |
&LITE |
Has the value 1 when running LISTSERV Lite and 0 otherwise. |
&LITEFE |
Has the value 1 when running LISTSERV Lite Free Edition and 0 otherwise. |
&TITLE |
The title of the list or empty string if no title is available. |
Content Filter
The CONTENT_FILTER mail template, if present, contains filtering rules, one rule per line. Each rule has the following format:
The prefix, if present, can be a mail header tag (for example "Subject:"); "Header:" to check the whole header; or "Text:" to search the message text. The latter is the default if no prefix is supplied. A text search will search every line of the first text/plain part in the message. If there is no text/plain part, there is no match.
Regular comparisons such as those described above are not case sensitive. Patterns are standard LISTSERV patterns. The asterisk is the wildcard character. If there is no asterisk in the pattern, it is replaced with "*pattern*".
The content filter also supports "exact match" comparisons, which are triggered by a double colon. For instance:
There are two significant differences between exact and regular match:
- You must supply your own wildcard characters in an exact match (if you want to use wildcards). A regular match will insert leading and trailing wildcards if none are found. Thus, an exact match is the only way to make a comparison without wildcards.
- You can make an exact match for the empty string. Empty regular matches are ignored. This also makes it possible to apply an exact match to a message that does not contain a specified header.
One of the most handy uses for the exact match syntax is to be able to write a rule to reject messages with blank subject lines. For instance:
Subject:: Action: REJECT Please resubmit your message with a non-blank subject.
Every rule can, optionally, be followed by an action rule. This has the following format:
Action: ALLOW Action: REJECT reason Action: DISCARD comment Action: MODERATE
The available actions are the same for both regular and exact comparisons. For instance:
Subject: Out of office Action: REJECT OOO messages are not allowed on this list. Subject: Auto-Generated: Action: REJECT Text: Click here to be removed Action: REJECT Buzz off, spammer. Subject:: Action: REJECT Please resubmit with a non-blank subject. Text: copyright Action: MODERATE To: friend@public.com Action: DISCARD This guy is a spammer
The default is "Action: REJECT" with no specified reason.
- REJECT means that the message is rejected. The text of the rejection is fetched from the BAD_CONTENT mail template form, with the reason supplied as a variable called &COMMENT.
- MODERATE means that the message is to be forwarded to the list editor to be manually approved or rejected.
- DISCARD means that the message is to be discarded without further processing; any text following DISCARD is echoed to the LISTSERV log file.
- ALLOW means that the message is allowed and all remaining rules are ignored. This could be used in moderated lists to allow certain posters to bypass certain filters, for instance:
Subject: Out of office Action: REJECT OOO messages are not allowed on this list. From: JOE@EXAMPLE.COM Action: ALLOW Text: Click here to be removed Action: REJECT Buzz off, spammer.
In the example above, messages with subject lines containing "Out of office" are rejected. Messages containing the text "Click here to be removed" are also rejected unless it came from joe@example.com.
Note: The CONTENT_FILTER is a data template. None of the usual mail template substitutions or commands are valid.
Using &DAYSEQ()
The DAYSEQ(n) function is quite powerful. This function allows the list owner to code templates like bottom banners that change or "rotate" automatically.
The DAYSEQ(n) function is invoked in a .BB .EB conditional block, and n corresponds to the number of days in the rotation period, in other words, the number of variations that you want to make to the text of the message. &DAYSEQ(n) returns a number from 1 to n which increases by 1 every day, with no special regard for weekends. If the rotation period should last for a week, you code DAYSEQ(7). If the rotation period is 15 days, you code DAYSEQ(15).
To create a rotating bottom banner, follow this example. A list has three commercial sponsors, each of whom are provided with an advertisement every three days. (Note that this doesn't take weekends into account; in this example, if company A is featured in the banner on Monday, it will be featured again on Thursday and then again on Sunday. However, in the following week it will be featured on Wednesday, Saturday and Tuesday). Our BOTTOM_BANNER template would look like this:
Today's copy of the &LISTNAME newsletter has been brought to you by .BB &DAYSEQ(3) = 1 Company A. .EB .BB &DAYSEQ(3) = 2 Company B. .EB .BB &DAYSEQ(3) = 3 Company C. .EB
If a company needs to get a higher percentage of "air time" than another, you can simply assign it more than one of the possible n values of &DAYSEQ(n). For instance, if you have two companies but one should get twice as many days of air time, you might code something like this:
Today's copy of the &LISTNAME newsletter has been brought to you by .BB (&DAYSEQ(3) = 1) OR (&DAYSEQ(3) = 3) Company A. .EB .BB &DAYSEQ(3) = 2 Company B. .EB
This would cause Company A's message to appear on days 1 and 3 of the rotation period and Company B's message to appear on day 2 only.
LISTSERV® is L-Soft's email list management software, originally developed by Eric Thomas in 1986. Visit the LISTSERV® Resource Center for more complete documentation.
LISTSERV® is a registered trademark. The trademark identifies LISTSERV® as a brand of email list management software developed by L-Soft.
|