Using patterns in hooks
Dear mutts, I am seeking a technical solution to a PEBCAK¹ case routed in my inability — at times — to think before I do. ;) ¹) http://en.wikipedia.org/wiki/Pebcak Basically, I would like to instruct mutt to refuse sending a message when any one (or both) of two cases is true: a. a message is somehow marked as not-yet-ready b. a message is addressed to a "problematic correspondent" and does not include a manual signed-off sentinel of sorts. The furthest I got on my way to address (a) was to use send2-hook to manipulate $sendmail: http://git.madduck.net/v/etc/mutt.git/commitdiff/ea36eed7af5f5e0e28b8d60f55abda2997cb1a08 (also see http://bugs.debian.org/584264). I don't like this solution very much, because it abuses the recipient list; apparently, one can only use a limited number of patterns in a send2-hook, and using e.g. ~h yields the error: h: not supported in this mode http://www.mutt.org/doc/devel/manual.html#pattern-hook says: Mutt allows the use of the search pattern language for matching messages in hook commands. This works in exactly the same way as it would when limiting or searching the mailbox, except that you are restricted to those operators which match information Mutt extracts from the header of the message (i.e., from, to, cc, date, subject, etc.). It's a bit ironic that ~h is not usable in hooks, but so be it (see http://bugs.debian.org/585764). I am now turning to you because you might have better ideas. Can you think of a sentinel that is usable in hooks which a. matches if present, thus making the hook execute as long as it exists (e.g. X-Draft: yes)? b. matches unless present, thus making the hook execute until I add it (e.g. X-Signed-off: yes)? I was thinking of using X-Label, but that seems to get eaten (http://bugs.debian.org/583251). Ideally, the solution does not abuse the recipient list, the sender, or the subject. What would you do? -- martin | http://madduck.net/ | http://two.sentenc.es/ "montag, why do you burn books?" "it's a job like any other, pay is good and there is a lot of variety." -- ray bradbury (f451) spamtraps: madduck.bo...@madduck.net digital_signature_gpg.asc Description: Digital signature (see http://martin-krafft.net/gpg/)
Re: Using patterns in hooks
On Sun, Jun 13, 2010 at 07:57:23PM +0200, martin f krafft wrote: > Dear mutts, > > I am seeking a technical solution to a PEBCAK¹ case routed in my > inability — at times — to think before I do. ;) > > ¹) http://en.wikipedia.org/wiki/Pebcak > > Basically, I would like to instruct mutt to refuse sending a message > when any one (or both) of two cases is true: > > a. a message is somehow marked as not-yet-ready > b. a message is addressed to a "problematic correspondent" and does >not include a manual signed-off sentinel of sorts. The following is a tip to check if you attached a file to a message, triggered when you use the "attach" word in the text body. http://wiki.mutt.org/?ConfigTricks/CheckAttach It might be a good solution for your problem; it doesn't use mutt's patterns, though. -- Javier Rojas GPG Key ID: 0x24E00D68 signature.asc Description: Digital signature
Re: Using patterns in hooks
On Sun, Jun 13, 2010 at 07:57:23PM +0200, martin f krafft wrote: > Dear mutts, > > [snip] > > Basically, I would like to instruct mutt to refuse sending a message > when any one (or both) of two cases is true: > > a. a message is somehow marked as not-yet-ready > b. a message is addressed to a "problematic correspondent" and does >not include a manual signed-off sentinel of sorts. > > The furthest I got on my way to address (a) was to use send2-hook to > manipulate $sendmail: > > > http://git.madduck.net/v/etc/mutt.git/commitdiff/ea36eed7af5f5e0e28b8d60f55abda2997cb1a08 > (also see http://bugs.debian.org/584264). > > [snip] > > I am now turning to you because you might have better ideas. Can you > think of a sentinel that is usable in hooks which > > a. matches if present, thus making the hook execute as long as it >exists (e.g. X-Draft: yes)? > b. matches unless present, thus making the hook execute until I add >it (e.g. X-Signed-off: yes)? > > I was thinking of using X-Label, but that seems to get eaten > (http://bugs.debian.org/583251). > > Ideally, the solution does not abuse the recipient list, the sender, > or the subject. What would you do? Hi, I think the securest solution would be to use a custom script as $sendmail which checks if a special header is present (like Really-Send: yes) and only pass the mail to the "real" sendmail if the header is present, otherwise exiting with code 1. If you combine it with additional checks you wouldn't have to add the header to every mail, which might get annoying otherwise. The major problem with this solution is the bug you mentioned above, that mails are added to $record even if $sendmail fails (Debian bug 584264). One way around that would be to let the custom script store the mails in $record. A special header (like My-Fcc: path/to/record) could be used to create a replacement for fcc-hooks (by using my_hdr in other hooks to set it), as fcc-hooks wouldn't work in this case. (This is a summary of a discussion in #mutt on Freenode about this problem). Simon -- + privacy is necessary + using gnupg http://gnupg.org + public key id: 0x92FEFDB7E44C32F9 pgpLMRDyen6RL.pgp Description: PGP signature
Re: Using patterns in hooks
also sprach Javier Rojas [2010.06.13.2055 +0200]: > The following is a tip to check if you attached a file to a message, > triggered when you use the "attach" word in the text body. > > http://wiki.mutt.org/?ConfigTricks/CheckAttach > > It might be a good solution for your problem; it doesn't use mutt's > patterns, though. Thanks for taking the time to reply! I am already using this approach (and found it to be quite useless since it's just a reminder à la "click enter to acknowledge", not an enforcer). Also, it is implemented in the editor (or the sendmail script), not inside mutt, as you say. Cheers, -- martin | http://madduck.net/ | http://two.sentenc.es/ "it is impossible to foresee the consequences of being clever." -- cristopher strachey spamtraps: madduck.bo...@madduck.net digital_signature_gpg.asc Description: Digital signature (see http://martin-krafft.net/gpg/)