+ Reply to Thread
Results 1 to 6 of 6

Thread: How to automatically send a reply mail using PHP?

  1. #1
    paidbrowse66 is offline x10Hosting Member paidbrowse66 is an unknown quantity at this point
    Join Date
    Aug 2010
    Posts
    15

    Question How to automatically send a reply mail using PHP?

    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??

  2. #2
    warlordste's Avatar
    warlordste is offline x10 Elder warlordste is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Wigan
    Posts
    653

    Re: How to automatically send a reply mail using PHP?

    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?
    "It's time to prove to your friends that you're worth a damn. Sometimes that means dying, sometimes it means killing a whole lot of people."- sin city "You either die a hero or you live long enough to see yourself become the villain" - TDK



  3. #3
    paidbrowse66 is offline x10Hosting Member paidbrowse66 is an unknown quantity at this point
    Join Date
    Aug 2010
    Posts
    15

    Re: How to automatically send a reply mail using PHP?

    #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!

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: How to automatically send a reply mail using PHP?

    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 by misson; 02-07-2011 at 04:21 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    paidbrowse66 is offline x10Hosting Member paidbrowse66 is an unknown quantity at this point
    Join Date
    Aug 2010
    Posts
    15

    Re: How to automatically send a reply mail using PHP?

    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?

  6. #6
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: How to automatically send a reply mail using PHP?

    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,
    Quote Originally Posted by misson View Post
    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
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. PHP send mail - Unable to send to Yahoo! email addresses
    By royyuuki in forum Programming Help
    Replies: 7
    Last Post: 03-02-2010, 10:09 AM
  2. cannot send, reply and forward
    By imajinn1 in forum Free Hosting
    Replies: 2
    Last Post: 02-28-2010, 03:44 PM
  3. cannot send, reply and forward mail
    By imajinn1 in forum Free Hosting
    Replies: 0
    Last Post: 02-28-2010, 10:46 AM
  4. Automatically Send Email
    By lelandstrott in forum Programming Help
    Replies: 2
    Last Post: 04-10-2009, 07:51 PM
  5. Replies: 3
    Last Post: 12-03-2007, 08:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers