2012-07-02 14 views
0

我正在一個非常具體的服務器配置Zend項目中,我們的生產環境是由兩個專用服務器組成的,一個用於公司的電子郵件, postfix服務器和我們在Apache2/Zend上運行的Web應用程序的其他服務器。Zend_Mail錯誤500> postfix/sendmail致命錯誤:-n選項不支持

這些服務器有兩個不同的IP,但在同一個網站域上工作。

現在,當我嘗試使用的電子郵件,郵件服務器發送電子郵件作爲發件人,從我的Zend_Mail得到一個錯誤500和email.err日誌告訴我:

後綴/ sendmail的[15782 ]:致命的:-n選項不支持

但是當我把當地的住址或空白的電子郵件,因爲它工作的發送者,所以我想我得到Web服務器的後綴踢出因爲它不管理這些電子郵件。

所以我的問題是:是否有任何方式使用域電子郵件作爲來自遠程服務器的發件人而不合並兩臺服務器?

編輯:我忘了補充:我不能使用遠程服務器SMTP,我只能使用本地sendmail。

回答

0

我還沒有找到任何解決方案或解釋,所以我最終通過編寫基於PHP的郵件命令的自定義操作助手。

我希望它可以幫助別人:

class Zend_Controller_Action_SentEmail extends Zend_Controller_Action_Helper_Abstract{ 

    public function sendEmail($from, array $to, $subject, $message){ 

     //Header set 
     $headers = 'MIME-Version: 1.0' . "\r\n"; 
     $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; 
     $headers .= "From: ".$from."<[email protected]>\r\n"; 
     $headers .= "X-Mailer: PHP/".phpversion(); 


     //To 
     $stringTo = ""; 

     foreach($to as $k => $v) { 
       $stringTo .= $k." <".$v.">, "; 
     } 

     $stringTo = trim($stringTo, ", "); 


     //Send the email 
     if(mail($stringTo, $subject, $message, $headers, "-f [email protected]")){ 
      return true; 
     } 
     else{ 
      //Oh! Noes! 
      return false; 
     } 
    } 
}