Home > MySQL, PHP > Parse Email – Save Attachments

Parse Email – Save Attachments

October 19th, 2009

We need a script that will parse multi-part emails. The script will be required to do the following:

Needs to be IMAP, SSL context (potentially using gmail).

1. Verify the following before doing anything else
- Fetch *new* emails (script will run from cron job)
- from address: will be the primary key for users. If email already exists, grab the user id. if it doesn’t, create a new user (id, email & name from headers).
- attachment type (only accept images)
- attachment size (needs to be a variable that we can change later if need be)

Once user is identified (fetched or created), we save the attachment.

2. Save the the email to a MySQL database
Whatever is needed to identify email , +
- user id
- subject
- date/time
- body (html/text)
- attachments (name of the attachment, location of the file on the server)

3. Save the file on the web server
- Location will be (uploads/yyyy/mm/dd/)

4. Send email to the user to confirm the process or inform of an error.

Nothing is set in stone, and any recommendation or advice is welcome.

** We require full ownership

** We require clean and detailed commenting within the code, we will review every line of code).

** If you have questions on any requirements please let us know.


Parse Email - Save Attachments

Categories: MySQL, PHP Tags: , , , , , ,
Comments are closed.
Bear