The Mutt E-Mail Client : Advanced Usage : External Address Queries
Previous: Message Matching in Hooks
Next: Mailbox Formats

## 4.5. External Address Queries

Mutt supports connecting to external directory databases such as LDAP, ph/qi, bbdb, or NIS through a wrapper script which connects to mutt using a simple interface. Using the $query_command variable, you specify the wrapper command to use. For example:

> `

>     set query_command = "mutt_ldap_query.pl '%s'"

> `

The wrapper script should accept the query on the command-line. It should return a one line message, then each matching response on a single line, each line containing a tab separated address then name then some other optional information. On error, or if there are no matching addresses, return a non-zero exit code and a one line error message.

An example multiple response output:

> `

>     Searching database ... 20 entries ... 3 matching:
>     me@cs.hmc.edu           Michael Elkins  mutt dude
>     blong@fiction.net       Brandon Long    mutt and more
>     roessler@guug.de        Thomas Roessler mutt pgp

> `

There are two mechanisms for accessing the query function of mutt. One is to do a query from the index menu using the query function (default: Q). This will prompt for a query, then bring up the query menu which will list the matching responses. From the query menu, you can select addresses to create aliases, or to mail. You can tag multiple messages to mail, start a new query, or have a new query appended to the current responses.

The other mechanism for accessing the query function is for address completion, similar to the alias completion. In any prompt for address entry, you can use the complete-query function (default: ˆT) to run a query based on the current address you have typed. Like aliases, mutt will look for what you have typed back to the last space or comma. If there is a single response for that query, mutt will expand the address in place. If there are multiple responses, mutt will activate the query menu. At the query menu, you can select one or more addresses to be added to the prompt.

The Mutt E-Mail Client : Advanced Usage : External Address Queries
Previous: Message Matching in Hooks
Next: Mailbox Formats