How to get incoming email via PHP and cPanel

This may be possible to do with other control panel software such as plesk, although I have only done so with cPanel

  1. Open your cPanel homepage, and navigate to the Mail panel
  2. Select the Default Address option
  3. At the bottom of the page, click the Advanced Options »
  4. Select the Pipe to a Program: radio option
  5. In the text field, enter the path from your home directory to the php script
  6. 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

Tags:

Leave a Reply

You must be logged in to post a comment.