Author: Brandon Long (blong@fiction.net) Original Date: 03-30-1998 Original Version: 0.90.11i Date: 04-09-1998 Version: 0.90.13i External Database Address Queries ================================== This patch adds something (in an alpha form) that I've been thinking about for a while, and finally decided just to do something, get people thinking about how it should be implemented differently, etc. It allows you to specify a new variable, $query_cmd, which is a string which contains a command to query an external database for email addresses. This string should contain %s which will be replaced by the query. In mutt, you use query (mapped to 'Q' by default) to bring up a query prompt. Then, you type your query, and mutt runs the query_cmd to get the list of applicable addresses. The format of the repsonse is a one line message, followed by multiple lines of tap dilineated address, name, other. This is then shown in a menu, where you can add an alias from an entry, mail a message to an entry, or tag multiple entries to mail a message to (it seems that mutt_create_alias() doesn't allow you to create an alias list, so tagging entries only creates an alias for the first tagged entry. I think this bug has been reported before). In addition, mutt will check the exit code of the query. A 0 exit code means no error, a different exit code flags an error, and mutt will ignore the response and print the first line returned as an error message. With this, one could write scripts to use ph, LDAP, bbdb, or whatever to return the results of your query. For instance, here at Intel, you can use the following query_cmd: set query_cmd = "phone -q -d BookName -c -DomainAddress -c -BookName -c -PhoneNum '%s'" which will use the phone script to query the phonebook database at phonebook.fm.intel.com At my webpage, there are currently scripts to query LDAP (by Marc de Courville), ph and user accounts (passwd). YMMV, let me know what you think. This version also supports query expansion during address entry, similar to the way mutt will expand aliases. If you type complete-query (default '^Q') at an address prompt, mutt will pass what you have typed (from either the beginning of the line or a comma or space) to the query_cmd. On a single match, it will expand in place, on multiple matches, the query menu will be presented, and one or more addresses can be chosen. Note that this patch moves the static function rfc822_append from send.c into rfc822.c, where I think it belongs (since I use it in query.c)