Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing php scripts in qmail files

Status
Not open for further replies.

s0crates9

Technical User
Jun 18, 2005
70
0
0
US
I am trying to find out how to get a hp script to run on incoming email.

I tried creating a file in /var/qmail/alias/ called ".qmail-emailaddress" which had in it: "|/dir/to/script/script.php".

I also tried to experienment sake, to create a user based alias file with the same name and entry.

So I tried actually testing the script by issuing a mail command in linux and, the email was delivered but did not activate the script. I am wondering if there is anything I am missing or doing improperly.

I made sure to also setup the script with permissions (755), and ensured that it had the php binary execution line (#!/usr/bin/php).

To no avail.

Thanks for any help with this!

Web site design, internet marketing, SEO and business solutions company.
 
You're right in your approach to qmail, wrong in running php from command line.

You do NOT insert the #!/usr/bin/php at the head of the script.

You NEED to include the actual php binary as part of the command.

Let's say that the binary 'php' is in my path, I can run the script 'hello.php' from command line as

"php hello.php"

If 'php' binary were not in the command line, I'd run it as

"/usr/local/bin/php hello.php"

and so on....

Your example in .qmail-emailaddress does not show the binary in your code. It should work properly if you do so.

D.E.R. Management - IT Project Management Consulting
 
Thanks thedaver.

I tried the suggestion and it is not working still. I would like to diagnose what the issue is...

This is what I have done-
I have run a commmand line like:
Code:
dhue-2833.3# echo "Test input" |/usr/local/bin/php /home/user/script.php
and this script works. I put into the script a "logging" function which just outputs a file that holds the input captured by the script.

However, when I try to issue:
Code:
dhue-2833.3# mail user-email@domain.com
Subject: Test Subject
Test message
.
EOT

the file is not created which means that the script was not run.

My question is: How do I go about finding out where the bottleneck is or why this script doesn't run when it is supposed to.

Thanks!

Web site design, internet marketing, SEO and business solutions company.
 
Thanks for the direction, I did however figure it out. I was placing the .qmail file into the wrong user directory, it should have been in the vpopmail directories!

Now I have another related issue which is getting the data into mysql. when I run php functions for mysql, they don't execute and when I do:
Code:
cat current
in the /usr/log/qmail directory, there are issues related to mysql_connect etc.

My question is, if the libraries are inaccessible for mysql, how do I get the data into a db?

I though about sending the data to a webpage (where apache and the php api can connect to mysql), but that seemed a bit like to much work. I would rather keep things simple.

Thanks for any help in this matter.

Web site design, internet marketing, SEO and business solutions company.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top