2013-02-07 49 views
1

我一直在尋找2天的答案,現在已經找到了這麼多,但仍然無法得到它的工作。管道郵件到php腳本

我有一個cPanel帳戶的WHM服務器。

我創建public_html下下面的PHP腳本在/home/USERNAME/help-system/parse.php來進行測試:

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

我也創建在的cPanel轉發轉發至:

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

PHP腳本和目錄的權限0755(也嘗試0777)

現在,當我發送電子郵件到正確的地址,我得到一個反彈的電子郵件,如:

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

我錯過了什麼?有沒有啓用WHM或cPanel設置?上面我做了一些愚蠢的事嗎?

任何幫助將不勝感激。

乾杯。

+1

我可能已經找到答案!在cPanel編輯器中編輯php文件,並在hashbang(shebang)後刪除換行符,然後重新放入。這擺脫了Windows新行,並添加在unix新行! –

回答

4

電子郵件管道,看起來像它不能理解Windows換行符!

所以:

  1. 創建PHP腳本
  2. 添加hashbang到腳本
  3. 上傳
  4. 公開賽中的cPanel的頂部 - >文件管理器 - >代碼編輯器
  5. 刪除換行符在hashbang之後,將其重新添加回
  6. 保存

所有現在工作

+0

謝謝!我不知道一個Windows新行和一個unix新行之間的區別可以通過這種方式從某人的生活中摧毀一天:( –