2011-08-25 33 views
0

我正在使用第三方SMTP服務發送我的通訊。因此,我的ISP不接受反彈,因爲它們來自不是源於他們的電子郵件。好的。因此,我使用SMTP服務設置了一個郵箱來接受反彈。我如何獲得Phpmailer郵件發送郵件與其他域的返回路徑

但是,我的郵件列表程序拒絕發送返回路徑與發件人字段不同的域的電子郵件。

我相信這是由PHPMailer的,在它的mailsend程序引起的:

的關鍵代碼看起來是這樣,但我沒有那麼多與PHP的專家找出如何繞過任何檢查正在做,我認爲這與safe_mode有關。我想使用的返回路徑值是變量函數:$ this->發件人

/** 
    * Sends mail using the PHP mail() function. 
    * @param string $header The message headers 
    * @param string $body The message body 
    * @access protected 
    * @return bool 
    */ 
    protected function MailSend($header, $body) { 
    $toArr = array(); 
    foreach($this->to as $t) { 
     $toArr[] = $this->AddrFormat($t); 
    } 
    $to = implode(', ', $toArr); 
    $params = sprintf("-oi -f %s", $this->Sender); 
    if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) { 
     $old_from = ini_get('sendmail_from'); 
     ini_set('sendmail_from', $this->Sender); 
     if ($this->SingleTo === true && count($toArr) > 1) { 
     foreach ($toArr as $key => $val) { 
      $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); 
      // implement call back function if it exists 
      $isSent = ($rt == 1) ? 1 : 0; 
      $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$ body); 
     } 
     } else { 
     $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); 
     // implement call back function if it exists 
     $isSent = ($rt == 1) ? 1 : 0; 
     $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$b ody); 
     } 
    } else { 
     if ($this->SingleTo === true && count($toArr) > 1) { 
     foreach ($toArr as $key => $val) { 
      $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); 
      // implement call back function if it exists 
      $isSent = ($rt == 1) ? 1 : 0; 
      $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$ body); 
     } 
     } else { 
     $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header); 
     // implement call back function if it exists 
     $isSent = ($rt == 1) ? 1 : 0; 
     $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$b ody); 
     } 
    } 
    if (isset($old_from)) { 
     ini_set('sendmail_from', $old_from); 
    } 
    if(!$rt) { 
     throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL); 
    } 
    return true; 
    } 

有誰知道這些代碼是如何阻止我使用不同的域名爲我的返回路徑,或更好然而,有沒有人知道我可以修復(或破解)這樣它會發送我的郵件?

+1

什麼是$ params調用mail()?你的'php.ini'中的'sendmail_path'是什麼? – sanmai

+0

@sanmai:上面我的代碼中顯示的$ params是:「-oi -f return-path」。我的sendmail_path是:「/ usr/sbin/sendmail -t -i」 – lkessler

回答

1

@三邁的評論讓我看着參數。當我開始在phpmailer例程中測試其中的一些時,我發現代碼沒有執行。所以至少他幫助我認識到問題在別的地方。

我仍然有問題。我現在試着更好地隔離它。那麼也許我可以解決它,如果沒有,我會修改這個問題,然後再試一次。

謝謝你給我一點點繼續。

0

你得到了什麼錯誤?可能是因爲您使用的郵件服務器不允許使用不同的返回地址域來阻止其服務用於發送垃圾郵件。

+0

沒有@JJ,它不是服務器。因爲它發生在腳本中。當我將返回路徑設置爲:[email protected]並在2封電子郵件中進行測試時,它將顯示發送:0中的2,然後是第二秒中的2中。但是,我必須做的是更改返回 - 路徑爲:[email protected],它只是在那裏發送:0出2。 – lkessler