不能用cakeemail发送附件

时间:2015-05-02 07:43:52

标签: cakephp

我无法通过电子邮件发送附件。我没有收到错误,我确实发送了邮件,因此电子邮件无效,但没有附件。

我的文件路径不正确,因为此文件中存在该文件?是因为我使用带文件路径的窗口吗?

这只是下面的测试电子邮件,看看这个功能是否真的适用于附件,但它对我不起作用。我检查了其他答案,这似乎是构建它的方法。

http://book.cakephp.org/2.0/en/core-utility-libraries/email.html

   public function sendEmailattach($to,$message,$subject,$attach) {



                        $Email = new CakeEmail();
                             $Email->config('gmail3'); 
                            $Email->filePaths  = array('D:\crm5\app\Attachments');

                     $Email->attachments =array('Ch9-anna tax.docx');
                             $to='jXXXXX@gmail.com';//testing real email account
                           //  $Email->from( array('admin@a.com.au' => 'A'));
                                 $Email->from( array('jxxxxx@gmail.com' => 'test'));



                             $Email->to($to);
                             $Email->subject($subject);
                             $Email->send();
                              // $Email->send($message);



  }//public


UPDATE
Tried all 3 methods and no error and no attachment?
 //  $Email->attachments('D:\AA-website design\crm5\app\Attachments\Ch9-anna tax.docx') ;

                    $Email->attachments(array('Ch9-anna tax.docx' => array(
                            'file' => 'D:\AA-website design\crm5\app\Attachments\Ch9-anna tax.docx',
                               )   ));     

                  //   $Email->attachments(array('D:\AA-website design\crm5\app\Attachments\Ch9-anna tax.docx'));

1 个答案:

答案 0 :(得分:1)

只需阅读手册而不只是查看链接,老实说,我怀疑你是否读过它:

http://book.cakephp.org/2.0/en/core-utility-libraries/email.html#sending-attachments

它清楚地表明附件是一种方法而不是财产。它甚至还有该方法接受的例子。