2014-11-05 53 views
0

我寫了一個PHP腳本,它發送郵件。我從「[email protected]」發送郵件,並將「返回路徑」設置爲「[email protected]」,但我仍然收到發件人郵件的郵件(「[email protected]」 「)。PHPMailer反彈郵件沒有得到反彈

這裏被剝離下來代碼:

$this->mail = new PHPMailer(); 
$this->mail->isSMTP(); 
$this->mail->Host = 'host'; 
$this->mail->SMTPAuth = true; 
$this->mail->Username = '[email protected]'; 
$this->mail->Password = 'pass'; 
$this->mail->SMTPSecure = 'tls'; 
$this->mail->Port = 25; 
$this->mail->ReturnPath = '[email protected]'; 
$this->mail->From = '[email protected]'; 
$this->mail->send(); 

我怎麼能強迫反彈郵件去反彈郵件帳戶?謝謝你的幫助!

回答

8

請勿使用ReturnPath - 請設置Sender。 PHPMailer(版本5.2.8)最近禁用了對ReturnPath屬性的支持,因爲在發送時將其設置爲無效。返回路徑在收到消息時由接收方添加,並通過將所需的返回路徑放入Sender屬性中進行設置,該屬性在SMTP會話期間作爲信封發送方傳遞。

$this->mail = new PHPMailer(); 
$this->mail->isSMTP(); 
$this->mail->Host = 'host'; 
$this->mail->SMTPAuth = true; 
$this->mail->Username = '[email protected]'; 
$this->mail->Password = 'pass'; 
$this->mail->SMTPSecure = 'tls'; 
$this->mail->Port = 25; 
$this->mail->setFrom('[email protected]'); 
$this->mail->Sender = '[email protected]'; 
$this->mail->send(); 
+2

對我來說這一個工作,$ Sender是,當你調用setFrom,但是你可以重寫它,只是把它直接,這樣的自動設置mail-> Sender ='[email protected]';因此,您的答案很可憐,我們不接受... – Terradon 2015-10-06 22:21:26

+0

我使用PHP_Mailer 5.2.10,我的PHP版本是5.4.9。 「$ this-> mail-> Sender」不適合我。所有退回的電子郵件都將返回到「$ this-> mail-> AddReplyTo」地址。這是否($ this-> mail-> AddReplyTo)導致「$ this-> mail-> Sender」的任何問題發揮作用? – Kiran 2016-03-18 15:32:12

+0

爲什麼使用PHP和PHPMailer的老版本,buggy,不安全的版本?除此之外,還有很多郵件服務器會做錯事情。 – Synchro 2016-03-18 16:18:02