Concrete5.7.5.2 - 表单文件附件放在哪里headers?

Concrete5.7.5.2 - Where to put form file attachment headers?

我这样构建我的电子邮件 headers:

$txt_message .= $this->txt_message;
$html_message .= $this->html_message;
$mh = Core::make('helper/mail');
$mh->to($this->email_to, $this->site_name);
$mh->from($this->email, $this->name);
$mh->replyto($this->email, $this->name);
$mh->setSubject($this->subject);
$mh->setBody($txt_message);
$mh->setBodyHtml($html_message);
@$mh->sendMail();

一些 post 说可以添加附件

$mh->addAttachment($file);

但 $file 必须是文件 object。如何让上传的文件成为文件object?

我也找到了这个post:http://www.adrikodde.nl/blog/2012/mail-attachments-concrete5/

但是我遇到了所有 Zend 内容的错误。 Zend Mail 在 C5.7 中仍然可用吗?

文件附件 headers 放在哪里?我在哪里可以找到更多关于真正发送邮件的信息(它仍然是 Zend Mail 吗?)以及可用的方法?

谢谢。

[已解决]
感谢 Nicolai,这是一个附加文件的工作示例:

$file = $_FILES['image']['tmp_name'];
$filename = $_FILES['image']['name'];
$importer = new \Concrete\Core\File\Importer();
$file_version = $importer->import($file, $filename);
$attachment = $file_version->getFile();
$mh->addAttachment($attachment);

//Delete the file if not wanted on server
$attachment->delete();

PS。在尝试发送文件之前,请务必selected/exists/uploaded 检查文件!

if (!empty($this->image)) {
    $importer = new \Concrete\Core\File\Importer();
    $image_version = $importer->import($this->image, $file_name);
    if ($image_version instanceof \Concrete\Core\File\Version) {
        $attachment = $image_version->getFile();
        $mh->addAttachment($attachment);
    }
}
@$mh->sendMail();

要将文件添加到您的文件系统,您应该看看这个

http://concrete5.org/api/class-Concrete.Core.File.Importer.html

关于返回的对象(成功时是 FileVersion),您应该能够调用 getFile( ) 来获取实际的 Concrete5 File 对象