mailReader.php version 3 is here!
mailReader.php is a PHP script which handles incoming email messages, saving attachments to disk, and logging emails to a database.
Download it from GitHub now: https://github.com/stuporglue/mailreader
E-mail Processing Script Features:
- Saves the e-mail sender, subject and body to a database
- Saves any attachments as files and creates an entry for those files in the database, associated with the e-mail info in #1
- Sends a response back to the sender telling them what files were received and their file sizes
- Checks a list of allowed senders to make sure we only take files from specified addresses.
Improvements in Version 3
mailReader.php is growingup a little bit more. It’s now a class instead of just a script. A new script mailPipe.php uses the mailReader class to achieve the same results the script did previously.
I did some database renaming so that none of the fields are reserved names, and they don’t need to be escaped anymore.
I updated the database connection code from mysql_connect to PDO.
I added support for uuencoded attachments. Uuencoded messages don’t have their mime-type detected, but everything else is the same as mime attachments.
Make sure that your upload directory is out of your webroot. If someone emails you a malicious PHP script (eg. Virus.php) and can access it via the web, they could infect your server or your visitors. Many servers are configured to automatically treat .pl and .cgi as CGI scripts and run them as well. You do not want to create a way for untrusted users to upload files to your webroot!
With the file names in the database you can use Readfile to pass files down to users.
I welcome any contributions which others may benefit from, so if you hack on it, consider submitting a pull request on GitHub.