我使用这个cakephp电子邮件插件从帐户拉电子邮件。以下是我的参数
'datasource' => 'Emails.Imap',
'server' => 'mail.example.com',
'connect' => 'imap/novalidate-cert',
'username' => 'username',
'password' => 'password',
'port' => '143',
'ssl' => false,
'encoding' => 'UTF-8',
'error_handler' => 'php',
,我按照文档
中的指示进行查询$ticketEmails = $this->TicketEmail->find('first', array('recursive' => -1));
,但是当我调试结果时,以下字段显示如下数据
Array
(
[TicketEmail] => Array
(
. . . other fields
[body] => CjxIVE1MPjxCT0RZPnNvbWUgbWVzc2FnZTxicj48L0JPRFk+PC9IVE1MPgo=
[plainmsg] => IHNvbWUgbWVzc2FnZQo=
. . . other fields
)
)
我不明白为什么它显示这些字符串,例如在电子邮件帐户的消息的正文只是这个文本some message
。
我的蛋糕版本是1.3
谢谢!
这是Base64编码,看起来插件不处理,它只检查quoted-printable
格式。
您可以解码模型中的数据,例如在model::afterFind()回调中或在自定义方法中,或者您可以尝试修改插件,以便它返回解码的数据(未经测试):
protected function _fetchPart ($Part) {
$data = imap_fetchbody($this->Stream, $Part->uid, $Part->path, FT_UID | FT_PEEK);
if ($data) {
// remove the attachment check to decode them too
if ($Part->format === 'base64' && $Part->is_attachment === false) {
return base64_decode($data);
}
if ($Part->format === 'quoted-printable') {
return quoted_printable_decode($data);
}
}
return $data;
}