cakeemail和gmail smtp如何更改FROM字段?

时间:2012-11-06 03:11:17

标签: email cakephp smtp gmail

我正在使用cakephp 2.2

这是我在Config / email.php中设置的smtp

public $gmail = array(
        'host' => 'ssl://smtp.gmail.com',
        'port' => 465,
        'username' => 'appmailer@someapp.com',
        'password' => 'somepassword',
        'transport' => 'Smtp'
);

这是我的电子邮件设置。

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

$email = new CakeEmail('gmail');
$email->from(array('bigshot@company.com' => 'On Behalf of Big Shot'));

$email->to('client@bigshotclient.com');
$email->subject('[Test -- please ignore] one last test. Remember to hit REPLY to this email');
$email->sender('appmailer@someapp.com');
$email->replyTo('bigshot@company.com', 'Big Shot');

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

发送电子邮件时,FROM地址会重复显示

On Behalf of Big Shot<appmailer@someapp.com>

如何才能将FROM显示为bigshot@company.com的原始电子邮件地址?

顺便说一下,replyTo效果很好。

我正在尝试完善所有的邮件投递。

1 个答案:

答案 0 :(得分:1)

显然,Gmail SMTP将始终覆盖FROM字段以防止发送垃圾邮件。

请参阅https://stackoverflow.com/a/3872880/80353

如果有人可以帮助附上说明这一点的实际GMail文档,那就太棒了。