tags:

views:

76

answers:

1

Hi, I don't know much about this and was just curious because i had an idea :) I know with my cPanel hosting i can pipe an email inbox to a script, but what i want to do is:

  1. send to [email protected]
  2. pipes to mail.php
  3. mail.php reads the subject, and a .txt attachment
  4. the contents of the subject and .txt attachment are stored in the database

Is there a way to do this with straight forward PHP?

A: 

You'll probably need do the following:

  1. Write a PHP script that's executable at the CLI (by adding a #! declaration at the top of the script that points to the PHP binary, then settings its executable permissions).

  2. Get that script to read the raw email from php://stdin (file_get_contents is easiest)

  3. Get that script to decode the mail in to parts, using something like PEAR::Mail::Mime::Decode or I think there's a handy Zend Framework component).

  4. Read the attachment and subject from the decoded message, and store as normal

  5. exit(0) at the end to tell the CLI that it was a clean exit - any other exit() status could cause a bounced email.

Ciaran McNulty
Thanks! I am new to executable files, so will need to look into it, do you know any links that might be useful to me :)
tarnfeld