Concrete5.7.5.6 / PHP 5.6.30 / SMTP:是
我有一个使用sendmail发送通知的自定义块,但主题行显示utf-8编码。您在日志中看到的编码相同。
=?UTF-8?Q?Brochure=20aanvraag, =20gebouw=2002=20-=20Appartement=20A105?=
我试图找出失败的原因。 (没有自己制作块。)
$mh->setSubject($this->parseString($this->emailSubject));
$mh->setBodyHTML($this->parseString($this->emailContent));
@$mh->sendMail();
parseString返回替换了vars的字符串,如果我将其删除它只显示相同但没有替换:
=?UTF-8?Q?Brochure=20aanvraag, =20gebouw=20{{=20page::building=20}}=20-=20?= {{ page::name }}
奇怪的部分:这只发生在实时服务器上,从localhost版本发送的邮件按预期工作(干净的电子邮件主题)。 - 本地php版本:5.6.10
默认的formblock没有这个问题。
[更多信息] parseString函数
protected function parseString($string = null)
{
if (!$this->currentPage) {
$this->currentPage = Page::getCurrentPage();
}
preg_match_all('/{{ ([a-z]+)::([a-z0-9]+) }}/', $string, $matches);
if ($matches) {
foreach ($matches[0] as $k => $v) {
$replacement = $v;
switch ($matches[1][$k]) {
case 'page':
switch ($matches[2][$k]) {
case 'name':
$replacement = $this->currentPage->getCollectionName();
break;
case 'link':
$replacement = $this->currentPage->getCollectionLink();
break;
default:
$replacement = $this->currentPage->getAttribute($matches[2][$k]);
break;
}
break;
case 'post':
$postValue = $this->post($matches[2][$k]);
if (trim($postValue) != '') {
$replacement = $postValue;
}
else {
$replacement = '';
}
break;
}
$string = preg_replace("/$v/", $replacement, $string);
}
}
return $string;
}