Reputation: 2034
i want to send email with some attachment in cakephp.
here is my code:
$Email = new CakeEmail('default');
$Email->from(array('[email protected]' => $message['Message']['subject']))
->to($email)
->sender(array('[email protected]' => $message['Message']['subject']))
->replyTo(array('[email protected]' => $message['Message']['subject']))
->subject($message['Message']['subject'])
->attachments(array(
1 => 'http://test.com/files/message_file/file/9/56b22b15b3cec.jpg'
))
->send($message['Message']['description']);
but i face to this error when i run it:
File not found: "http://test.com/files/message_file/file/9/56b22b15b3cec.jpg" Error: An Internal Error Has Occurred.
Upvotes: 2
Views: 2836
Reputation: 753
Use sever absolute path to file for attachment
$Email
->attachments(array(
1 => WWW_ROOT . 'files' . DS. 'message_file' . DS . 'file'.DS.'9'.DS.'56b22b15b3cec.jpg'
))
Upvotes: 4