45.5. Creating and Editing Variable Assignments

Procmail actions can make use of shell-style variables in their conditions and delivery destinations. For example, you could create an action that delivers to the file /mail/$LOGNAME, in which $LOGNAME is the username of the user to whom email is being delivered. Several variables (like .LOGNAME and DEFAULT) are set automatically by Procmail, while others can be set in the configuration file for later use. You can even override the automatic variables to change the behavior of the program, such as the default delivery destination or shell to use for executing commands.

To create a new variable assignment, follow these steps:

1.
On the module's main page, click on the Add a new variable setting link below the list of existing actions. The variable creation form will be displayed.

2.
In the Variable name field, enter the name of the variable to set, such as DEFAULT. All automatic variables have uppercase names, and those that you create yourself should as well. No spaces or nonalphanumeric characters are allowed.

3.
In the Value field, enter the value to assign to this variable, such as Maildir/. The value can include references to other variables.

4.
Hit the Create button to add the variable to the list on the main page.

5.
Use the up arrow next to the new variable in the list to move it to the correct location, which will typically be at the top of the file. Variable assignments only effect actions and assignments after them, so one added at the bottom may not have any effect.

As with actions, a variable can be edited or deleted by clicking on its name in the list. Variables can also be moved about with the up and down arrows next to them. Because they only effect actions and other assignments below them in the file, you will certainly want to move any new variable up to near the top of the list. One added and left at the bottom will not have any effect (except on the default delivery destination).

Procmail defines and allows you to change several special variables. The names and meanings of the most interesting ones are listed in Table 45.1.

Table 45.1. Variables Set by Procmail for Use in Actions
Variable namePurpose
DEFAULTThe destination to which email that does not match any action will be delivered. Changing this variable will modify the default destination, which is the best way to have email delivered to a mail directory or file in users' home directories. To specify a directory put a / at the end of the path, such as Maildir/. As with destinations in an action, a nonabsolute path is assumed to be relative to the recipient's home directory.
HOMEThe home directory of the user to whom mail is being delivered.
SHELLThe UNIX shell of the recipient. Sometimes it is necessary to set this for commands to be properly executed.
LOGNAMEThe username of the UNIX user to whom mail is being sent.
ORGMAILThe original default delivery destination, such as /var/spool/mail/$LOGNAME. Changing this variable, however, does not effect Procmail's behavior.
SENDMAILThe command that Procmail will run to forward email to another address, if specified by an action. You may want to change this if Sendmail is not installed on your system, as it defaults to /usr/sbin/sendmail.
SENDMAILFLAGSThe command-line parameters passed to the $SENDMAIL command.
HOSTYour system's hostname, as reported by the hostname command.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.168.83