merefolk has asked for the wisdom of the Perl Monks concerning the following question:

Can Perl read the body of an incoming email and then determine where to forward the email? An example would be - I have family on both sides (mom's family and dad's family). These 2 families will be the groups with a list of emails that may change from time to time. An email comes in one email address - myfamily@family.com Perl needs to read the body of the email IF the body has 'mom's family' in the text it will forward that to mom's family group. Which in turn shoots out to all the emails in that group. This is just an example, but it would have SEVERAL words and SEVERAL groups that would determine where to forward to. Thanks, Adam
  • Comment on Can Perl read the body of an email to determine where to forward that email?

Replies are listed 'Best First'.
Re: Can Perl read the body of an email to determine where to forward that email?
by halley (Prior) on Dec 17, 2007 at 18:29 UTC
    • Can it see the body of the email? Yes.
    • Can it look for keywords in a string of text? Yes.
    • Can it do some email-sending of its own? Yes.
    That's easy. But...
    Judy, I know you said you didn't want to spend yet another Thanksgiving with mom's family, so I told them that you were studying for finals. Wish I had that excuse. Uncle Jack will bore us all with his boring slideshows again. Tell me how Vegas is later!

    --
    [ e d @ h a l l e y . c c ]

      But....? What? :) That is the jist of it from your example. The only thing I might change is when the person is sending the email to family@family.com , they would put mom's family in the first line.
        He just pointed out a case in which you might want to think twice before forwarding that to the other family.. They might not take it as lightly as you ;)
Re: Can Perl read the body of an email to determine where to forward that email?
by gloryhack (Deacon) on Dec 17, 2007 at 20:13 UTC
    This sounds like a job for the CRM114 discriminator. I'm not aware of a general purpose perl interface for it, but the SpamAssassin CRM114 plugin might give you a good start on rolling your own.

    CRM114 project page on sourceforge

    crm114.pm

    Some training will be required. If you have a good sample of mail whose correct disposition is known, you can build corpora from them to train the discriminator. Be forewarned, though, that (as with any other solution you're likely to implement) there will be times when CRM114 gets it wrong and you'll have to reschool it.

    Good luck in your quest, and have fun with it.