I had the following bit of perl that strips all attachments from stdin and returns stdout which may be of help:
#!/usr/bin/perl -w
use strict;
use Mail::Audit;
use Mail::Audit::Attach qw(Attach);
my $mail = Mail::Audit->new;
my $attachments = $mail->attachments;
foreach (@$attachments)
{
$_->remove;
}
$mail->print();
and than a simple loop over the files in your Maildir you want stripped of attachments for isntance:
for filename in <list>
do
./strip.pl < "$filename" > "$filename".lock && mv "$filename".lock "$filename"
rm "$filename".lock
done
An interesting modification could be to first extract the attachments and store them separately first before deleting them from the mails:
foreach (@$attachments)
{
$_->save("/path/to/attachment/dir");
$_->remove;
}
Make a back-up first though ;)
You can configure mutt to use different from addresses (via your ~/.muttrc
), e.g.:
set use_from = yes
set envelope_from = yes
set from = default@example.org
set realname = "Default Realname"
# list of all your addresses
alternates @example\.org$
You can setup some macros to explicitly switch the from before composing a new mail:
macro index \e1 "set from=foo@example.org\n" "Select foo address"
macro index \e2 "set from=bar@example.org\n" "Select bar address"
# ...
When replying to an email, you can configure mutt to automatically use the to-header as from address (this is point 2 from your question):
set reverse_name=yes
Don't reuse the real name - helps when people send you crap like "foo@example.org" <foo@example.org>
:
set reverse_realname=no
Then you can set up some hooks to make things depend on header values - e.g. to use different fcc folders:
fcc-hook '~f ^foo@example\.org' '=foo'
(There are also other hooks, like send-hook
etc.)
I would look into the hooks to implement something like point 1 from your question. Although, you would need some external scripting to maintain such a database.
Depending on your current MTA setup you may have to change its config as well, i.e. such that it accepts different envelope froms.
It is also possible to use different SMTP relays depending on e.g. the hostname of the envelope from - but this must be configured in the MTA.
Best Answer
I believe I found a solution to this on the Mutt wiki.
I find this confusing and badly explained, but I tried it by adding
set timeout=30
to my~/.muttrc
and it seems to work! The inbox view updates not long after my IMAP daemon reports having downloaded new mail. I hope this works for you too!