How to get incoming email via PHP and cPanel
Tuesday, June 24th, 2008This may be possible to do with other control panel software such as plesk, although I have only done so with cPanel
- Open your cPanel homepage, and navigate to the Mail panel
- Select the Default Address option
- At the bottom of the page, click the Advanced Options »
- Select the Pipe to a Program: radio option
- In the text field, enter the path from your home directory to the php script
- Enter the following code in your script file
#!/usr/bin/php -q
That will collect all the information from the email sent to you, and store it in the $email variable. You will need to add the code after the fclose() for anything to happen with the email, such as save it to a file or parse it for data, or else it will be lost forever. This method will retrieve all headers as well as the data, just for you to be aware