By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,027 Members | 1,088 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,027 IT Pros & Developers. It's quick & easy.

using same script in email handling and POST web form

P: n/a
Hi All, I have a script sitting on my web server called
auto_mail.php5. I would like this to be used two different ways.

One way would be for a web form to call it as submit action on a form.
I have got this working great.

However, to get this to work I had to comment out the first line of
the script which is #!/usr/bin/php -q

Now the other way the script is called doesn't work any more! This
other way is that when xx**@beckhallmalham.com receives an email it
forwards the email to |/home/beckhall/public_html/php/auto_mail.php5

Since I removed that first line the forwarder never invokes the
script! If I put the first line back in then the forwarder works but
the web post does not. This is because the web post later does a
HEADER("newurl") to do a redirect, and this fails as text has already
been posted to the form. catch-22!

Any suggestions? I would guess but I'm no expert that the best
solution would be to tell the email forwarded to use php to process
the auto_mail.php5, but I don't know how to do this! Maybe the
forwarder to go to another script, that then calls auto_mail.php5?

Cheers for any help,

Simon
Jul 22 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Jul 22, 3:35 pm, simon m <SIMON.MA...@usa.netwrote:
Hi All, I have a script sitting on my web server called
auto_mail.php5. I would like this to be used two different ways.

One way would be for a web form to call it as submit action on a form.
I have got this working great.

However, to get this to work I had to comment out the first line of
the script which is #!/usr/bin/php -q

Now the other way the script is called doesn't work any more! This
other way is that when x...@beckhallmalham.com receives an email it
forwards the email to |/home/beckhall/public_html/php/auto_mail.php5

Since I removed that first line the forwarder never invokes the
script! If I put the first line back in then the forwarder works but
the web post does not. This is because the web post later does a
HEADER("newurl") to do a redirect, and this fails as text has already
been posted to the form. catch-22!

Any suggestions? I would guess but I'm no expert that the best
solution would be to tell the email forwarded to use php to process
the auto_mail.php5, but I don't know how to do this! Maybe the
forwarder to go to another script, that then calls auto_mail.php5?

Cheers for any help,

Simon
forward the email to |/usr/bin/php -q /home/beckhall/public_html/php/
auto_mail.php5

(check the path of PHP - it may not be /usr/bin/php)

C.
Jul 23 '08 #2

P: n/a
>
forward the email to |/usr/bin/php -q /home/beckhall/public_html/php/
auto_mail.php5
Hi All, I just tried the above but the control panel which I think is
cpanel X on Apache 1.3.37 (Unix) on a shared server parses out the /
usr/bin/php -q bit when I paste it into the "forward to" box. There is
also some help text that says no need to put the php or cgi bits in,
but be sure to place the appropriate shebang at the top of the script.
Argh!

How about a php script that the email forwards to withe shebang, that
can calls auto_mail.php5? Is there a way to do this, like #include
another php script in another one?

Simon

Jul 24 '08 #3

P: n/a
simon m escribió:
>forward the email to |/usr/bin/php -q /home/beckhall/public_html/php/
auto_mail.php5

Hi All, I just tried the above but the control panel which I think is
cpanel X on Apache 1.3.37 (Unix) on a shared server parses out the /
usr/bin/php -q bit when I paste it into the "forward to" box.
Then you'll need to write a small shell script to launch it, let's say
"auto_mail.sh":

#!/bin/bash
/usr/bin/php -q /home/beckhall/public_html/php/auto_mail.php5

And you would forward e-mail to |/path/to/auto_mail.sh

--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jul 24 '08 #4

P: n/a
Álvaro G. Vicario escribió:
Then you'll need to write a small shell script to launch it, let's say
"auto_mail.sh":

#!/bin/bash
/usr/bin/php -q /home/beckhall/public_html/php/auto_mail.php5

And you would forward e-mail to |/path/to/auto_mail.sh
Hmmm... Now I think about it, I'm not sure my sample script is quite
right... Maybe you need to pass the standard input to the *.php file :-?

I'm sorry, I should not be writing bash scripts when I don't have any
Unix box where to test them.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jul 24 '08 #5

P: n/a
sorted! I have the original script auto_mail.php5, without the shebang
and the webpage calls this. All works OK.

the email now goes to iknow_wrapper.php and this has the shebang in
it, then an include("auto_mail.php5") in it and that's all.

yeah! Thanks for all the pointers. I use www.php.net as a mega
resource, but like a lot of documentation it only really helps when
you know how to do something and need to clear up the details!

Simon
Jul 24 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.