Help for Alpine - Roles
You are in Home > Roles


  1. Introduction
  2. How do Roles Work?
  3. How Do I Set up a Role?
  4. Setting the From Field
  5. Setting the Fcc Field
  6. Setting the Signature for a Role
  7. The Template File
  8. List of Typical Mistakes
  9. Starting a New Message with a Role
  10. Setting Other Headers
  11. Configuration Options Related to Roles


A role gives you the ability to change your identity, signature or set headers in a e-mail. You may think that there's nothing special about this, since one can always change the headers and signatures in every message just by editing them. But let's say that whenever you post to a newsgroup you always want the same signature, which is different from the one you use to send messages to your boss, and you would like therefore this set automatically. That's what roles are for.

People usually say that they "set a role" when they start composing a message, meaning that they choose an "identity" or "personality". For example, if you are the president of your company, you can have messages whose signature will be different when you write a business e-mail than when you write a message to a family member or friend, and all of this done automatically by Alpine.

The only thing you must not forget is that once a role is set, you can not change it. If you want to change the role, you must restart the composition of your message again, and choose the right role (or no role). Unfortunately because of the way that Alpine is designed, there's nothing that can be done to remedy this situation. The good news is that there are ways to configure Alpine so that you will always be able to configure which role to use.

How do Roles Work?

Every Role has two parts, the conditions and the action part. The conditions are several configuration options which you must set in order for the role to be activated (e.g. The message that you are replying to is from a specific mailing list). A role is used if all conditions that are tested are satisfied (with exceptions to be discussed later). When you set up a role you must indicate an action. For example an action may be "set the signature file to be a specific file, which is different from my main signature file and set the from line to look in a very specific way". As you will see later, the fact that an action is set does not mean that the action will be executed, there are few configuration options that relate to roles, which override the actions you may choose in each role.

Every time you start to compose a message (by either replying to a message, starting a fresh one or forwarding a message), Alpine goes through your list of roles, and tests each one, if it finds a match (that is, if it tests all the conditions in the role and all of them are satisfied), it will check to see if it must use it, or it must ask you if you want to use it or if you do not want to use it at all. Here's what happens next:

  1. If the role is configured to be used without confirmation, then Alpine will go ahead and use it, no questions will be asked.
  2. If the role is configured so that Alpine must confirm with you to use it, then a confirmation prompt will appear. If you answer yes, then the role will be used, if you answer No, then Alpine will not use any role, at all. If you intended to use a role, you must press ^T, instead of answering "No", to select another different role. I think that the next best thing here is that a "No" answer to this question is to keep scanning for a new match, and offer the next possible match. This is not what happens, though.
  3. If the role is configured to never be used, even if it is a match, then Alpine will keep scanning the list of roles to determine the first match that it finds where it has to either confirm its use or use under any circumstance.

How Do I Set up a Role?

To get to the Roles setup screen you must press M S R R. The most important commands are ? to help on how to set up roles, and A to add a role. Remember to give a good nickname to each role that you create so that you can go back to them later if changes are necessary in the future.

The part that needs to be set up in the headers, status and folder section is setup in the same way than you do it for filters, and the explanation can be found here. Just change the word filter by role where appropriate.

Setting the From Field

One of the main uses of a role is to be able to set a custom From field. In this way you get the From field set automatically. Simply add the value to the variable Set From. Something like

Set From         = Peter Flinstones <>
works well.
Tip: Every time that you add a role and change the From field in this way, add the address (in the above example to the Alternate Addresses (pinerc name: alt-addresses) configuration option. This option can be found in the setup menu: From the main screen press S C to find it. The reason you want to do this, is so that Alpine will know this address is yours and therefore messages addressed to the address in the From: field, will not be copied to you when you reply to them.

Setting the Fcc Field

This is a tricky part, because the Fcc field can be set in several different parts in your configurations (e.g. you can set a Fcc for a friend in your addressbook, and also a global Fcc: in your .pinerc file). The obvious question is which setting has priority. The rule here is this: "if you set a value in the role, that value will be used, regardless of any other configuration options"

Notice that the default text for this option in the role configuration screen is misleading. In fact, when you first start to configure a role, you will see the following text:

Set Fcc         = <No Value Set: using "value from fcc-name-rule">.

This text implies that if you do not set this value, then your default "sent-mail" folder will be used. This is not quite true, the complete truth is that this value is used only if the Fcc: folder is not set in the addressbook for the specific recipient of the message (in which case it would use that value for the Fcc:) or if the recipient is not in your addressbook.

If you set this configuration option to be <Empty Value> (which is obtained by deleting the value "No Value Set" of this variable), it means that no copies of any messages sent using this role will be kept. Remember that <Empty Value> is a value for the Fcc, which implies that it overrides any other configuration for Fcc you may have somewhere else.

Setting the Signature for a Role

Read all the information concerning a signature, including their use in roles, in the signature section.

The Template File

A template is a file that contains text that will be inserted into the message that you are composing when using a specific role. Notice that this text is put at the beginning of the message. In some sense you can think of it as a signature file, but it also has several differences that are worthwhile mentioning here.

It is similar to a signature file in the sense that is can contain tokens, that are expanded, in the same way that you can include tokens in a signature file. When replying you could use this file to generate a reply-leadin-string, the problem with this method of doing things is that you will have two reply-leadin-strings generated by Alpine every time you reply to a message, so you will have to delete one when starting a message.

The Template File could also include a text that you will always want included in your messages. A fancy way to use this could be to make Alpine include automatically the sentence "Dear _FROM_", where _FROM_ is expanded to the name of the person as appears in the From field. A still fancier way to do this that does not include any text if there's no personal name in the from field is to include the Template file to be

_ADDRESS_("_FROM_", "", "Dear _FROM_: ")

(the above says that if _ADDRESS_ is equal to "_FROM_", which only happens when there's no personal name in the From: field of the message, do not write anything, but if they are different, write "Dear _FROM_:").

A template file is different from a signature file, since two lines are prepended to the signature, instead a template file is not prepended with empty lines. You can also make the text in the template file a script, like for the signature, but no parameters are passed by Alpine to the script.

In order to create a template file, you must put the cursor on the configuration option and press "F" (the obvious letter "E" means Exit). If you already have a template file that you want to use, you can use "A" to add its location, or "T" to find it. The obvious subcommand "^T" of the "A" command does not exist.

The location of the template file can be local or remote. The syntax for remote access is the same as for the inbox-path.

List of Typical Mistakes

Since roles and filters are set in a similar way, people make the same mistakes that they would do for filtering, and they can be read here.

Starting a New Message with a Role

This is part of a bigger issue, which is the "C"ompose command.

Tradition indicates that for starting a new message you must press the "C" command. When you have set up roles, you have another choice: the "#" command. If you've never setup any roles, you will never know about them by starting a fresh message.

There are several possibilities, let's list them all and see how we can configure them:

Setting Other Headers

You can set more headers, as many as you want. Again the same rules about priorities are valid, anything set here, overrides any value set in your customized-hdrs option or in your default-composer-headers configuration options.

The way to set them is fairly easy, all you need to do is add the name of the header, with its value, say something like:

Set Other Hdrs  = X-My-Header: This is my header

Notice that this variable can contain a list of headers, there's an implication to that, which implies that you can not write a comma "," in the text of the header at all, so for example,

Set Other Hdrs  = X-My-Location: Vancouver, Canada.

is not valid text. This is because the comma "," is used by Alpine to separate entries in variables that are lists in the configuration file (your .pinerc file). Therefore the above text will look as if you entered two headers). You can get around this problem, however by entering the text that contains the commad between quotes, so

Set Other Hdrs  = X-My-Location: "Vancouver, Canada"

would work. Notice that this work around does not work very well when you want to add a list of nicks from your address book, for example

Set Other Hdrs  = To: "Peter, Wilma"

will not add the address of Peter Flintstone and Wilma, to the the To: field, it will instead add a text like

To: "Peter, Wilma"

However, if you added directly

Set Other Hdrs  = To: ","
then Alpine would add these addresses to the To: field, and fill out the personal names of these addresses, if they are found in your addressbook.

Configuration Options Related to Roles

In the configuration screen of Alpine (press M S C to get there), there are a few options that affect the way that roles work. Here they are all explained.
You are in Home > Roles