我正在使用 CakePHP,我需要发送带有附件的电子邮件,这是我的代码
function sendAsEmail($data) {
App::import('Component', 'Email');
$user = $this->Sender->find('first', array(
'conditions' => array('Sender.id' => $data['Message']['sender_id']),
));
$Email = new EmailComponent();
if ($this->useDbConfig == 'test') {
$Email->delivery = 'debug';
}
$Email->sendAs = 'html';
$Email->from = 'info@admin.ca';
$Email->return = Configure::read('App.systemAdminEmail');
$Email->bcc = array($data['Message']['recipient_text']);
$Email->attachments = $data['Message']['attachments'];
$Email->subject = $data['Message']['subject'];
$content = $data['Message']['message'];
$replyToAddress = isset($data['Message']['reply_to_address']) ?
(bool)$data['Message']['reply_to_address'] : false;
if (!$replyToAddress) {
$content .= "\n\n".__("Please do not reply to this email", true);
} elseif (!empty($data['Message']['reply_to'])) {
$Email->replyTo = $data['Message']['reply_to'];
}
if (Configure::read('App.systemAdminEmail')) {
$Email->additionalParams = '-f'.Configure::read('App.systemAdminEmail');
}
$Email->send($content);
return true;
}
我在 $data['Message']['attachments'] 上有我的附件,但我仍然无法在电子邮件中看到附件
有什么帮助吗?