Thread: procmail w/ PG.
hi, I seem to have found a good solution for getting email into a Pg db, only problem is I'm not good enough with procmail scripts to do it. I'l like procmail to filter out the To, From, Date, Subject, Body and complete header of the email. Then either stick it in a DB, or pass that info to a Perl script to stick in in the DB. Anyone know of such a script? Or an example I can work with? Thanks Jason -- ............. ......... Jason C. Leach ...... University College of the Cariboo ... jcl@mail.ocis.net. .. http://www.ocis.net/~jcl . Debian!Linux!
"Jason C. Leach" wrote: > I'l like procmail to filter out the To, From, Date, Subject, Body and > complete header of the email. Then either stick it in a DB, or pass > that info to a Perl script to stick in in the DB. > > Anyone know of such a script? Or an example I can work with? Caveat emptor, as I haven't done it yet, but there are a few procmail examples of how to filter and pass email to other programs, perl included, at http://www.tamucc.edu/~compserv/lman/other/procexamples/index.html The relevant examples look something like this one, which sends all mail with 'Digest' in the subject to a mail reformatting program called formail (see man formail): :0 * ^Subject:.*Digest |formail +1 -d -s procmail This sounds like a task well-suited to perl regular expressions with DBI/DBD::Pg. I found it quite worthwhile when setting up procmail to spend some time carefully reviewing the various procmail filter options (on the man page) that follow the colon. They allow you to chain filters together and control the flow and exit point of mail through your filter chains. Cheers. Ed Loehr
hi, That looks promising. Any idea where the mail reformatted 'formail' gets the input email? From STDIN? J Ed Loehr wrote: > "Jason C. Leach" wrote: > > > :0 > * ^Subject:.*Digest > |formail +1 -d -s procmail > > This sounds like a task well-suited to perl regular expressions with > DBI/DBD::Pg. I found it quite worthwhile when setting up procmail to > spend some time carefully reviewing the various procmail filter options -- ............. ......... Jason C. Leach ...... University College of the Cariboo ... jcl@mail.ocis.net. .. http://www.ocis.net/~jcl . Debian!Linux!