简体   繁体   English

管理电子邮件到PHP脚本

[英]Piping email to php script

I've been searching for an answer for 2 days now and have found so much, but still can't get this to work. 我一直在寻找2天的答案并找到了这么多,但仍然无法让这个工作。

I have a WHM server with a cPanel account. 我有一个带有cPanel帐户的WHM服务器。

I have created the following php script under public_html at /home/USERNAME/help-system/parse.php for testing: 我在/home/USERNAME/help-system/parse.php的public_html下创建了以下php脚本进行测试:

#!/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: 我还在cPanel中创建了一个转发到以下内容的转发器:

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

The php script and directory have permissions 0755 (also tried 0777) php脚本和目录有权限0755(也尝试过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? 是否有WHM或cPanel设置我还没有启用? Have I done something stupid with the above? 我上面做过些蠢事吗?

Any help would be much appreciated. 任何帮助将非常感激。

Cheers. 干杯。

Email Piping, looks like it can't understand the windows newline! 电子邮件管道,看起来无法理解windows换行!

So: 所以:

  1. Create php script 创建PHP脚本
  2. Add hashbang to the top of the script 将hashbang添加到脚本的顶部
  3. Upload 上传
  4. Open in cPanel -> File manager -> Code editor 在cPanel中打开 - >文件管理器 - >代码编辑器
  5. Delete the newline after the hashbang and add it back in 在hashbang之后删除换行符并将其重新添加
  6. Save

All working now 一切正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM