Email Pipe to Program - PHP - cPanel

27 February 2011, 1:48 AM

Simple code to allow you to pipe an email to PHP using Forwarder setup with cPanel. You can use by setting up a new Forwarder and using Advanced options.

To pipe you will need to enter this in the box requires changing the root to your PHP file.

/usr/bin/php -q /home/user1/scripts/pipemail.php

pipemail.php must have permission 0775

Contents of pipemail.php are as followed 

#!/usr/bin/php -q

// read from stdin

$fd = fopen("php://stdin", "r");

$email = "";

while (!feof($fd)) {

    $email .= fread($fd, 1024);

}

$lines = explode("\n", $email);

$myFile = "contentsOfMail.txt";

$fh = fopen($myFile, 'w') or die("can't open file");

fwrite($fh, $email);

fclose($fh);

?>


Categories

All
General
Applications
Code
Networking
 

 

 

Recent blog posts

4

Cent OS adding port into iptables - command line SSH
4 August 2013, 10:06 AM - Read More
   

17

Convert NSTimeInterval to NSString - iOS Development
17 September 2012, 4:38 PM - Read More
   

12

Find string in NSArray and return index of string - iOS Development
12 September 2012, 3:54 PM - Read More
   

Recent apps

Slots!
Read More
   
MobileRota
Read More
   
Eleven2
Read More
   

 

Customer Support

Need help with a product?
Product Support


Contact

Drop us a line?
hello@olliekett.com
   
Follow us on Twitter
@okdltd