I need a small script that will run as a cron job on a web server. Purpose is to fetch mail from a mail server, modify and forward emails if certain criteria’s are fulfilled. (The forwarded emails will be fetched via satellite phone or SSB radio so sizes must be limited.)
1. Definition of email addresses, servers, passwords etc. Forward email address for each. (This can be a simple array updated directly in PHP-program.)
2. List of criteria’s:
2a. Leading text in subject line for emails to forward (typically a few uncommon letters like "QQ:")
2b. Maximum size i kb
3. Loop fetching new emails for each email address
3a. Skip emails without correct leading string in subject.
3b. Skip all attachments
3c. Truncate email to roughly maximum size
3d. Change content to plain text
3e. Send email.
4. Mark, update a list, db table or something so the same email is not handled and again!
5. End program
Volume is low. Less than 10 forwarded emails per day. Cron will run maybe once an hour.