简体   繁体   中英

fullBaseUrl not correctly used for images when sending mails via console

We recently switched our mail implementation to be console-based.

Unfortunately, the following Helper-code within an e-mail view is now broken:

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

Although we set CakeEmail's domain var to the correct value:

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

The helper produces the following

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

Current behavior: The asset timestamping of the file just works like a charme, but the fullBase is unfortunately, I think due to the console call, the UNIX-path of the file.

Expected behavior: The fullBaseUrl should be the domain, which we're setting in the CakeEmail object.

Folks: Is there any other possibility, besides putting the domain on my own to the $this->Html->image() call?

CakeEmail::domain doesn't do what you want

The domain function is not there for configuring the base url in assets, it's purpose is to serve as the host name for the message id . A quick look at the code , and checking where $this->_domain is used should confirm that it's only use is related to message headers.

fullBaseUrl

The option to set is App.fullBaseUrl either by calling Router::fullBaseUrl :

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

Or by configuring it directly in core.php :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM