I am working over to send email with attachments.
I am using php default configurations to send email but using CakePHP framework.
$fromEmail = $from_name." <".$from_email.">";
$this->Email->from = $fromEmail;
$this->Email->to = trim($email);
$this->Email->subject = $subjects[$this->params['action']];
$this->Email->sendAs = 'text';
$this->Email->template = $this->params['action'];
print_r($attachments); exit; // Gave me an empty Array ( )
$this->Email->attachments = $attachments;
$attachments = array( );
if ( ! empty($this->data['Submit']['files'])) {
$attach_files = $this->Document->DocumentDocument->find('all', array(
'conditions' => array(
'MailDocument.Mail_id' => $this->data['Submit']['prop_id'],
'MailDocument.id' => $this->data['Submit']['files'],
),
));
$attachments = Set::combine($attach_files, '/PropertyDocument/file', '/PropertyDocument/file_path');
}
I understand we have to define file path in cakePHP.
Where am I going wrong?
You set an array containing the paths to the files to attach to the attachments property of the component.
The first file
att.docwill be attached with the same filename. For the second file we specify an aliasatt2.docwill be be used for attaching instead of its actual filenamesome-name.