如何使用CakePHP 1.3发送带有附件的电子邮件?

如何使用CakePHP 1.3发送带有附件的电子邮件?,cakephp,cakephp-1.3,Cakephp,Cakephp 1.3,我正在努力发送带有附件的电子邮件。 我使用php默认配置发送电子邮件,但使用CakePHP框架 $fromEmail = $from_name." <".$from_email.">"; $this->Email->from = $fromEmail; $this->Email->to = trim($email); $this->Email->subject = $subjects[$this->params['action']]; $th

我正在努力发送带有附件的电子邮件。 我使用php默认配置发送电子邮件,但使用CakePHP框架

$fromEmail = $from_name." <".$from_email.">";
$this->Email->from = $fromEmail;
$this->Email->to = trim($email);
$this->Email->subject = $subjects[$this->params['action']];
$this->Email->sendAs = 'text';
$this->Email->template = $this->params['action'];
print_r($attachments); exit; // Gave me an empty Array ( )
$this->Email->attachments = $attachments;

$attachments = array( );
            if ( ! empty($this->data['Submit']['files'])) {
                $attach_files = $this->Document->DocumentDocument->find('all', array(
                    'conditions' => array(
                        'MailDocument.Mail_id' => $this->data['Submit']['prop_id'],
                        'MailDocument.id' => $this->data['Submit']['files'],
                    ),
                ));
                $attachments = Set::combine($attach_files, '/PropertyDocument/file', '/PropertyDocument/file_path');
            }
$fromEmail=$from_name.“;
$this->Email->from=$fromEmail;
$this->Email->to=trim($Email);
$this->Email->subject=$subjects[$this->params['action'];
$this->Email->sendAs='text';
$this->Email->template=$this->params['action'];
打印(附件);退出;//给了我一个空数组()
$this->Email->attachments=$attachments;
$attachments=array();
如果(!empty($this->data['Submit']['files'])){
$attach_files=$this->Document->DocumentDocument->find('all',数组)(
“条件”=>数组(
'MailDocument.Mail_id'=>$this->data['Submit']['prop_id'],
'MailDocument.id'=>$this->data['Submit']['files'],
),
));
$attachments=Set::combine($attachment_files、/PropertyDocument/file、“/PropertyDocument/file_path”);
}
我知道我们必须用cakePHP定义文件路径


哪里出错了?

您设置了一个数组,其中包含要附加到组件附件属性的文件的路径

$this->Email->attachments = array(
    TMP . 'att.doc',
    'att2.doc' => TMP . 'some-name'
);
第一个文件
att.doc
将附加相同的文件名。对于第二个文件,我们指定了一个别名
att2。doc
将用于附加,而不是其实际文件名
某些名称