Click to See Complete Forum and Search --> : Procmail recipe trouble


dpipper
04-07-2003, 08:52 PM
My wife has an email account at work and home. Somehow the home email is being used by some of her colleagues. I would like to identify the email coming to her home address and forward it to her work. The catch is the home email is also still used by us, sometimes for home use otherwise I'd just forward everything.

So can I catch the incoming mail from say (her@homeaddy.com) and search the body of the message for her name and then forward it to her work email (her@workaddy.com), plus save a copy on my machine for now.

Thanks for any help.

The Kooman
04-08-2003, 12:48 AM
I can think of more than one solution depending on the setup:


Ask senders to use the name of the recipient on the 'To' field of the email. So mails to your wife would be "Your Wife <home@home.addr>" while mails to you would have "You <home@home.addr>" in the "To:" field. Notice that the names are different, but the email addresses are the same. Now you can use procmail to classify mail based on the pattern in the 'To' field. Needless to say, this can be generalized to more recipients on the same address. I feel this is the best way because there is no ambiguity about who the mail was destined for. The flip side is that 'Bcc's won't work since procmail won't be able to see anything to sort your mail
'grep'ing in the body is not foolproof since somebody can send you a mail asking you about your wife. If you just grep for her name in the body, the mail will go to her instead of you. But if you insist on greping the body, use the 'B' flag in the start of your recipe:

:0 B
* wife's-name
! wife@office.addr

Like I said, plenty of holes with that ;)


HTH