通过控制台发送邮件时,fullBaseUrl未正确用于图像

时间:2013-10-28 08:17:19

标签: php email cakephp cakephp-2.4

我们最近将邮件实施切换为基于控制台的。

不幸的是,电子邮件视图中的以下帮助程序代码现在已损坏:

$this->Html->image('file.png', array('fullBase' => true)

虽然我们将CakeEmail的域var设置为正确的值:

$email->domain('www.domain.tld');

助手产生以下

http://home/www/domain.tld/htdocs/img/file.png?1382530379

当前行为: 该文件的资产时间戳只是一个魅力,但不幸的是,我认为由于控制台调用,该文件的UNIX路径为fullBase。

预期行为 fullBaseUrl应该是我们在CakeEmail对象中设置的域。

伙计:除了将域名单独用于$ this-> Html-> image()之外,还有其他可能吗?

1 个答案:

答案 0 :(得分:1)

CakeEmail :: domain不能做你想做的事

域功能不适用于在资产中配置基本网址,其目的是serve as the host name for the message id。快速查看the code并检查使用$this->_domain的位置应确认其唯一用途与邮件标题相关。

fullBaseUrl

通过calling Router::fullBaseUrl设置App.fullBaseUrl的选项:

// inside email-sending command, before sending an email
Router::fullBaseUrl('http://example.com');

或直接配置in core.php

// anywhere before an email is sent
Configure::write('App.fullBaseUrl', 'http://example.com');