I’m trying to send an email with an attachment using CakePHP 2.0.
The file is submitted by the user via a form.
So far I have:
App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail();
$email->attachments = array($this->data['Opportunity']['resume_file']['tmp_name']);
$email->viewVars(array('name' => $this->data['Opportunity']['name']));
$email->template('application')
->emailFormat('html')
->to(TEST_CONTACT)
->from(EMAIL_CONTACT)
->subject('New application received')
->send();
The email sends and looks fine, but there is no attachment.
What am I doing wrong?
For some reason CakePHP won’t do attachments unless you state the
filePaths first.
I have the same problem and I did not manage to find many answer to
this question. It took me a while to solve the problem, to clarify,
I got it working by
http://groups.google.com/group/cake-php/browse_thread/thread/93a9c9467733fe38?pli=1