How do I send an email with an attachment in CakePHP 2.0?
cakephp, cakephp-2.0
Solution
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
$this->Email->filePaths = array('/home/username/');
$this->Email->attachments =array('article_button.png');
$this->Email->to = 'em...@email.co.uk';
$this->Email->subject = 'Something';
$this->Email->replyTo = $client['Client']['email'];
$this->Email->from = $client['Client']['email'];
$this->Email->sendAs = 'html';
if($this->Email->send('Testing', null, null)){
die('Email Sent!');
}else{
die('Failed to send email');
}
http://groups.google.com/group/cake-php/browse_thread/thread/93a9c9467733fe38?pli=1
Problem
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?