How to automatically send a reply mail using PHP?

paidbrowse66

New Member
Messages
15
Reaction score
0
Points
0
Respected members,
Here is my problem:
Suppose a user sends a mail to example@mydomain.com
I then want to run a PHP script with the from, subject, and content fields of the mail and then reply accordingly.
I know how to send mails using mail() function. But, how can I call the PHP script on receiving any mail??
 

warlordste

New Member
Messages
653
Reaction score
0
Points
0
the only way i can think of is by using a cron jobs but i don't think your allowed to use them on x10 hosting could you not use a auto reply?
 

paidbrowse66

New Member
Messages
15
Reaction score
0
Points
0
#1 Cron jobs is allowed on x10's servers. But, on the condition that no two crons will run with an interval less than 5 minutes!
#2 Autoresponder will not work because:
If the subject is UNSUBSCRIBE, I want to add the email address in unsubscribed list
IF the subject is SUBSCRIBE, I want to remove the email address from the list.

Can I do this with an Autoresponder? I doubt!
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
In cPanel, you can forward e-mails to a program, which should get the e-mail on standard input. Make sure you use the full path to php ("/usr/local/bin/php-cli" or "/usr/local/bin/php" should work), include any necessary arguments (such as "-q" to suppress HTTP header generation for the non-CLI PHP interpreter) and use the full path to the script.

Even though forwarding an e-mail directly to a program is possible, batch processing may be more performant, depending on how many e-mails the script has to handle.
 
Last edited:

paidbrowse66

New Member
Messages
15
Reaction score
0
Points
0
Thanks for the reply.
But, I have another problem, on sending mails to that address *(eg@example.com), I get a delivery faillure message!
The following text was generated during the delivery attempt:

------ pipe to |/home/(location to file)/responder.php
generated by eg@example.com ------

Can't do setuid (cannot exec sperl)
X-Powered-By: PHP/5.2.13
Content-type: text/html
Then I googled with the query Can't do setuid (cannot exec sperl)
Then, I saw this one as authentic:
Your perl script sometimes work from the command line but shows “Internal Server Error” on accessing the script via the browser. The Apache error logs shows the error message as

“Can’t do setuid (cannot exec sperl)”.

The the reason for the setuid error on the perl script is the script have the setuid bit set and won’t work from the browser since they are running under the user apache. To make such perl scripts work, you need to install the perl-suidperl package.

To install the package, just execute the command

yum install perl-suidperl
But How do I execute this command? Is this to be done by the staff?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
I see you didn't enter a shebang line, as the document linked in the previous post shows.

Don't pipe the e-mail directly to the script, pipe it to PHP, telling it which script to execute. As stated previously,
Make sure you use the full path to php ("/usr/local/bin/php-cli" or "/usr/local/bin/php" should work), [...]
Trying to execute the script directly will be too much of a hassle.

Code:
|/usr/local/bin/php -q /home/path/to/responder.php
 
Top