2012-11-06 43 views
1

我使用CakePHP 2.2cakeemail和gmail smtp如何更改FROM字段?

這是我的SMTP設置在配置/ email.php

public $gmail = array(
     'host' => 'ssl://smtp.gmail.com', 
     'port' => 465, 
     'username' => '[email protected]', 
     'password' => 'somepassword', 
     'transport' => 'Smtp' 
); 

這是我的電子郵件設置。

App::uses('CakeEmail', 'Network/Email'); 

$email = new CakeEmail('gmail'); 
$email->from(array('[email protected]' => 'On Behalf of Big Shot')); 

$email->to('[email protected]'); 
$email->subject('[Test -- please ignore] one last test. Remember to hit REPLY to this email'); 
$email->sender('[email protected]'); 
$email->replyTo('[email protected]', 'Big Shot'); 

$email->send('Remember to hit REPLY to this email'); 

當發送電子郵件,發件人地址顯示反覆

On Behalf of Big Shot<[email protected]> 

我怎麼可以把它使得FROM出現[email protected]的原始電子郵件地址?

順便說一句,replyTo工作得很好。

我正在嘗試完善郵件投遞。

回答

1

顯然,Gmail SMTP將始終覆蓋FROM字段以防止垃圾郵件。

https://stackoverflow.com/a/3872880/80353

如果有人可以幫助附加實際GMail的文檔說明了這一點,那將是巨大的。

+0

這完全有道理!所以請始終使用ReplyTo作爲您的原始電子郵件地址。 – mark