<<< Date Index >>>     <<< Thread Index >>>

Re: Setting the "From", depending on the Recipient



On Fri, Nov 14, 2003 at 12:31:11AM +0100, Martin Hasenbein wrote:

> 1. I've set up a few send-hooks to change my From:-line depending
>    on who I send mail to:
> 
> send-hook .                   'my_hdr From: Martin Hasenbein <mh@xxxxxxx>'
> send-hook '~t @space.net'     'my_hdr From: Martin Hasenbein <mh@xxxxxxxxx>'  
>  
> send-hook '~C @hasenbein.com' 'my_hdr From: Martin Hasenbein 
> <martin@xxxxxxxxxxxxx>'

That's fine.

> Now, if I send out an eMail to someone, the first From:-line is used.
> If I send an eMail to one of my colleagues (*@space.net), the second
> From:-line is used. And if I send an eMail to a member of my family
> (*@hasenbein.com), the third From:-line is used. That works perfect!

...as you yourself pointed out :-)

However, here's where it gets a tad hairy:

> But I also have defined some folder-hooks for e.g. the mailing-lists:

> folder-hook =mailings/mutt 'my_hdr From: Martin Hasenbein 
> <mh-mutt@xxxxxxxxxxxx>'
> folder-hook =mailings/mutt 'set record=/home/mh/emails/archives/mutt-out'

folder-hooks, as their name implies, are called when you change to
a folder.  send-hooks, on the other hand, are called when you actually
try to compose a message.  If you change to a folder with a folder-hook
setting the From: header, and then try sending a message, the send-hook
will be called, which will happily clobber your From: header.

> When I now change to the folder and try to send an eMail to this list,
> my From:-line doesn't change. It reminds "Martin Hasenbein <mh@xxxxxxx>".
> Why? Do send-hooks have a higher priority over folder-hooks? Or do I
> have to specify a send-hook for each mailing-list, I send eMails to?

...as you yourself pointed out, once again :-)

The simplest way around that problem is to define folder hooks like this:

folder-hook . "send-hook .                   'my_hdr From: Martin Hasenbein 
<mh@xxxxxxx>'"
folder-hook . "send-hook '~t @space.net'     'my_hdr From: Martin Hasenbein 
<mh@xxxxxxxxx>'"
folder-hook . "send-hook '~C @hasenbein.com' 'my_hdr From: Martin Hasenbein 
<martin@xxxxxxxxxxxxx>'"

folder-hook =mailings/mutt 'unhook send-hook'
folder-hook =mailings/mutt 'my_hdr From: Martin Hasenbein 
<mh-mutt@xxxxxxxxxxxx>'
folder-hook =mailings/mutt 'set record=/home/mh/emails/archives/mutt-out'

This way, most folders will have the standard send-hook rules you have
above for setting the From: header, but when you enter =mailings/mutt,
those rules are tossed and replaced by a single From: header setting.

> 2.) I also have specified alternates like this:
> 
> set alternates = 
> ((beastie|martin|mh)@(beastie|bsd|bsdcafe|bsdguide|bsdmail|bsdnet|got-root|hasenbein|linuxintern|spassnetz|unixpert).(de|com|name|net))
> 
> and a send-hook like this:
> 
> send-hook ~p 'my_hdr From: Martin Hasenbein <mh@xxxxxxxxxx>'

You want to set the From: header only if you're sending yourself
a message?  I fail to see the utility there :-(

> What I want to achieve now is, when someone sends eMail to e.g.
> "mh@xxxxxxxxxxx" and I reply to this eMail, that the From:-line
> automatically changes to "Martin Hasenbein <mh@xxxxxxxxxxx>".
> And when someone sends eMail to "martin@xxxxxxxxxxxx", that
> the From:-line changes to "Martin Hasenbein <mh@xxxxxxxxxxxx>".
> And so on ...

Here, we have a little quote from TFM:

reverse_name

Type: boolean
Default: no

It may sometimes arrive that you receive mail to a certain machine, move the
messages to another machine, and reply to some the messages from there. If
this variable is set, the default From: line of the reply messages is built
using the address where you received the messages you are replying to. If the
variable is unset, the From: line will use your address on the current
machine.

reverse_realname

Type: boolean
Default: yes

This variable fine-tunes the behaviour of the reverse_name feature. When it is
set, mutt will use the address from incoming messages as-is, possibly
including eventual real names. When it is unset, mutt will override any such
realnames with the setting of the realname variable.


This does exactly what you'd like it to.  However, it only sets the
_default_ From: header of your message.  Your hooks override the
default header in all cases anyway, though, so setting these will
have no observable effect.  I don't know of any simple solution to the
problem, and AFAIK, nobody else does, either (except getting mutt-guile,
of course!).

> The only thing, that works right now is, when I specify a fixed
> eMail-Adress, like, as above, "mh@xxxxxxxxxx". But it should
> change to the eMail-Adress the eMail has been sent to. Is there
> a way to solve this problem?

Yes, there are ways to solve the problem, but they're not pretty.
It's a problem I intend to put together a solution for, though, so
if you keep buzzing me every now and then (or checking my own config
[1]), you can find out when I finally put together a nice solution.
(I've already put together a rather neat solution for the mailing list
setting From: header problem, if you wanna check it out.  It's based
purely on send-hooks - no folder-hooks whatsoever.)

 - Dave

[1]
http://www.bigfatdave.com/dave/mutt/

-- 
Uncle Cosmo, why do they call this a word processor?
It's simple, Skyler.  You've seen what food processors do to food, right?

Please visit this link:
http://rotter.net/israel

Attachment: pgptFAfkme3xz.pgp
Description: PGP signature