Help needed with setting up email account to pipe into PHP script

They have: 9 posts

Joined: Jun 2007

I'm using cPanel 11 on my website. I'm trying to create one forwarding email account ([email protected]) to pipe into a php script but the pipe isn't calling the script.

Here is my forwarding/piping syntax:

[email protected] to /home/websitename/public_html/SMS.php

The script is set to 755.

I have other, regular forwards created and mail gets forwarded fine such as for sales, info, etc. to my hotmail account.

Here is the simple test script:

#!/usr/local/bin/php

<?php
mail
('[email protected]', 'Subject', 'Message', 'From: [email protected]');
?>

The script works if I run it from a browser and it works if I run it from the command line in SSH - that is, I get the email message.

It just doesn't execute when the email comes in addressed to [email protected] and piped into this script.

I have other php scripts successfully using the mail() function so that is enabled on the server.

Since the script works from two sources and not as being piped from an incoming email, I suspect the problem is in the piping syntax - I can't think of anything else ???

RalphF

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

What theme are you using with cPanel? I'm asking this because X3 provides extra options and wizards that previous themes don't.

My cPanel said to input the path to the script relative to your home directory. Also, make sure your path to php is correct (could be /usr/bin/php instead of /usr/local/bin/php).

They have: 9 posts

Joined: Jun 2007

My cPanel ver is 11 and the theme is X3.

My path to php is correct I've verified and I have many other php scripts running ok.

I do think the problem is with the piping syntax OR that the mail system (exim) isn't piping the incoming email over to the script at all.

I have another website account with cPanel at a different hosting company, I'm going to see if I can pipe this same script to an email address with them.

RalphF

They have: 1 posts

Joined: Jan 2011

cPanel should allow you to do this, but you'll still need to parse the email if you use the email parts, such as the attachment, plain text and HTML versions of the message. If you are pressed for time you might checkout a couple services that will parse an email and post the parts to your remote scripts. Here are some examples:
MailHooks: Free basic parsing of different email fields, but no attachments
http://mailhooks.com
MailNuggets: Premium service that will post an email in JSON and other formats, with attachments
http://mailnuggets.com

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.