I am trying to send an attachment with cakephp email, but only plain html sent and not a attachment.
The following code I am using.
$nmessage ="Hello Test\r\n\r\n";
$email = new CakeEmail();
$email->from(array('[email protected]' => 'Test'));
$email->filePaths = array('/screenshots/');
$email->attachments =array('Google-Maps-9.22.2.jpg');
$email->to('[email protected]');
$email->subject('Register a visit ');
$email->emailFormat('html');
$email->send($nmessage); // or use a template etc
To send attachments you can do it the following ways, first a string with the full path (notice there is no equals symbol, it's a function of the CakeEmail class).
Secondly is the same but wrapped in an array
Thirdly an array with keys to rename the file
And finally you can use nested arrays
So in summary, don't use
$email->attachments =
and make sure to provide the full path.http://book.cakephp.org/2.0/en/core-utility-libraries/email.html#sending-attachments