I wanted a script to automatically watch for new emails, get the sender, subject and attachments from them, move the attachments to a directory and insert sender/subject info into a MySQL database.
I needed a solution for extracing mail files from big UNIX-style mailbox files, then parse them and extract attachments separately.
Here’s the script that does the job.
The script works by periodically checking /var/mail/chat for size change, then getting all mails from that mailbox file to a temp directory (/tmp/chatmailparser/). Then sender & subject get extracted, decoded with an external PHP script:
1 2 3 4 5 |
Attachments are saved to the temp folder also using this Perl script:
1 2 3 4 5 6 7 8 9 10 11 12 |
After moving them to their destination (modifying filenames if files already exist), the script puts chat message data into a MySQL database.
I’m using this init script for starting the chatmailparser script.
Trackback responses to this post
About me
I'm Nonoo. This is my blog about music, sounds, filmmaking, amateur radio, computers, programming, electronics and other things I'm obsessed with.
... »
Trackback URL
No comments yet.