faqts : Computers : Databases : MySQL : Tips and Tricks

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

42 of 53 people (79%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How can I put the contents of received emails into the database automatically?

Jan 24th, 2000 21:26
Nathan Wallace, hypnos


Look at the tests/mail_to_db.pl perl script from the MySQL source
distribution.  Here's the "intro":

# This program takes your mails and puts them into your database. It 
# ignores messages with the same from, date and message text.
# You can use mail-files that are compressed or gzipped and ends with
# -.gz or -.Z.

I have been using this for awhile.  All my incoming mail (that passes
the spam filters) is delivered to the appropriate mailbox, and a copy is
put into another file.  A few times a day, a cron job runs the
mail_to_db.pl script and puts all those mails into a table on mysql.
Then, another script is run will takes those emails, and puts them into
another database.  This is because I want it organized a different way,
and with just certain headers.  The script works pretty good, I haven't
had any problems with it.