I’m working with CakePHP and i need to send email with attachment here is my code
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;
}
i have my attachments on $data[‘Message’][‘attachments’] and still i cant see the attachment on email
any help?
$Email->attachmentsexpects array containing the paths to the files to attach. Make shure you have in$data['Message']['attachments']array of paths, and not only the filenames…