473,386 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Pipe an email to a PHP script

I set up an email address on my server "post@domain.com" and I want every emailed received to be sent to a php script, call it script.php.

My hosting service uses CPanel11, where their forwarding function allows to pipe an email to a program.

I set it up as
|/home/ubitig/public_html/script.php

And the on top of that file I say
#!/usr/local/bin/php -q

And I changed the permissions on that php file to 755 to make it executable

This is all following instruction from cpanel and whatever I have been able to find on the web

When I send an email to that email address I get 1 of the three following errors:

1. "local delivery failed"

2.
Expand|Select|Wrap|Line Numbers
  1. Error in argument 1, char 3: option not found
  2. Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
  3.       php <file> [args...]
  4.  -a               Run interactively
  5.  -b <address:port>|<port> Bind Path for external FASTCGI Server mode
  6.  -C               Do not chdir to the script's directory
  7.  -c <path>|<file> Look for php.ini file in this directory
  8.  -n               No php.ini file will be used
  9.  -d foo[=bar]     Define INI entry foo with value 'bar'
  10.  -e               Generate extended information for debugger/profiler
  11.  -f <file>        Parse <file>.  Implies `-q'
  12.  -h               This help
  13.  -i               PHP information
  14.  -l               Syntax check only (lint)
  15.  -m               Show compiled in modules
  16.  -q               Quiet-mode.  Suppress HTTP Header output.
  17.  -s               Display colour syntax highlighted source.
  18.  -v               Version number
  19.  -w               Display source with stripped comments and whitespace.
  20.  -z <file>        Load Zend extension <file>.
  21.  -T <count>       Measure execution time of script repeated <count> times.
  22.  
3.

Expand|Select|Wrap|Line Numbers
  1. Usage: php [options] [-f] <file> [--] [args...]
  2.       php [options] -r <code> [--] [args...]
  3.       php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
  4.       php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
  5.       php [options] -- [args...]
  6.       php [options] -a
  7.  
  8.  -a               Run interactively
  9.  -c <path>|<file> Look for php.ini file in this directory
  10.  -n               No php.ini file will be used
  11.  -d foo[=bar]     Define INI entry foo with value 'bar'
  12.  -e               Generate extended information for debugger/profiler
  13.  -f <file>        Parse and execute <file>.
  14.  -h               This help
  15.  -i               PHP information
  16.  -l               Syntax check only (lint)
  17.  -m               Show compiled in modules
  18.  -r <code>        Run PHP <code> without using script tags <?..?>
  19.  -B <begin_code>  Run PHP <begin_code> before processing input lines
  20.  -R <code>        Run PHP <code> for every input line
  21.  -F <file>        Parse and execute <file> for every input line
  22.  -E <end_code>    Run PHP <end_code> after processing all input lines
  23.  -H               Hide any passed arguments from external tools.
  24.  -s               Output HTML syntax highlighted source.
  25.  -v               Version number
  26.  -w               Output source with stripped comments and whitespace.
  27.  -z <file>        Load Zend extension <file>.
  28.  
  29.  args...          Arguments passed to script. Use -- args when first argument
  30.                   starts with - or script is read from stdin
  31.  
  32.  --ini            Show configuration file names
  33.  
  34.  --rf <name>      Show information about function <name>.
  35.  --rc <name>      Show information about class <name>.
  36.  --re <name>      Show information about extension <name>.
  37.  --ri <name>      Show configuration for extension <name>.
  38.  
The contents of my php file send a simple test email back to my email address (I tested the script through the browser and it worked).

The difference between first and second error is that I removed any space between the "-q" and the opening tag of the php code "<?php".

I have tried a million combinations of different things and nothing seems to work. If anyone has experience with setting up pipes in cpanel or has any suggestions, it would be super helpful.

Thanks
A
Jun 22 '12 #1
3 3420
Luuk
1,047 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. cat file  | php -r ' $line = fgets(STDIN); echo $line; '
this should echo the first line of the file
Jun 22 '12 #2
Sorry..I'm not sure I understand. Where does this go?
Jun 22 '12 #3
Luuk
1,047 Expert 1GB
Its an example of how to pipe the output of a file (or process) to PHP.

If you have a something.php like this:
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/php
  2. <?php
  3. $line=fgets(STDIN); print $line."\n";
  4. ?>
  5.  
Than
Expand|Select|Wrap|Line Numbers
  1. echo "123" | something.php
Will produce as output:
123
Jun 23 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: mcp6453 | last post by:
I'm posting in desperation and hopes that someone has a script that will achieve these objectives: 1. Web interface using forms collects Name, Address, Email Address. 2. Web interface sends this...
6
by: Jeffrey Silverman | last post by:
Hi, all. Sorry, first off, for the kidna weird selection of crossposted groups, but this question touches on aspects of discussion in each of the groups. So I have a group of around 500 email...
6
by: bojanraic | last post by:
Hi! I recently started playing with Python CGI, and I was happy that my basic input-name--print-hello-name CGI form example worked, so I thought I should advance to somew\hat more complicated...
4
by: wayne | last post by:
I have a PHP email script running on two separate websites. Today, I received a form mail generated by the script from each site, with time stamps 10 minutes apart. The entered email address in...
9
by: Jerim79 | last post by:
I am no PHP programmer. At my current job I made it known that I was no PHP programmer during the interview. Still they have given me a script to write with the understanding that it will take me a...
5
by: ozzii | last post by:
Hi, I have a asp email script which uses cdosys to send emails with attahcments by iterating through a record set of 500 email addresses. However the script simply times out. I know you can...
20
by: Pete Marsh | last post by:
Wondering if anyone can see an error with this script. I get a server configuration error. THat could mean a module is not being loaded, but maybe there's a syntax error here, can anyone spot it?...
1
by: harekrishna | last post by:
Hiii Can some please check my email script. I have gone through it several times but my mails won't come!! here is the script thank you- . .
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.