Piping email to php script

跟風遠走 提交于 2019-12-11 08:53:11

问题


I've been searching for an answer for 2 days now and have found so much, but still can't get this to work.

I have a WHM server with a cPanel account.

I have created the following php script under public_html at /home/USERNAME/help-system/parse.php for testing:

#!/usr/local/bin/php -q
<?php
mail('****@davidslack.co.uk', 'Test email', 'Test email to get an email into the script');
?>

I have also created a forwarder in cPanel that forwards to:

|/home/USERNAME/help-system/parse.php

The php script and directory have permissions 0755 (also tried 0777)

Now, when I send an email to the correct address I get a bounce back email like:

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed:

  pipe to |/home/USERNAME/help-system/parse.php
    generated by *********@davidslack.co.uk
    local delivery failed

The following text was generated during the delivery attempt:

------ pipe to |/home/USERNAME/help-system/parse.php
       generated by *********@davidslack.co.uk ------

Extension '/home/USERNAME/help-system/parse.php' not present.

------ This is a copy of the message, including all the headers. ------

What have I missed? Is there a WHM or cPanel setting I haven't enabled? Have I done something stupid with the above?

Any help would be much appreciated.

Cheers.


回答1:


Email Piping, looks like it can't understand the windows newline!

So:

  1. Create php script
  2. Add hashbang to the top of the script
  3. Upload
  4. Open in cPanel -> File manager -> Code editor
  5. Delete the newline after the hashbang and add it back in
  6. Save

All working now



来源:https://stackoverflow.com/questions/14757430/piping-email-to-php-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!