/** * Add attachment to send with an email. * * Sample Code: * $attachment = $mailHelper->addAttachment($fileObject); * $attachment->filename = "CustomFilename"; * $mailHelper->send(); * * @param \Concrete\Core\File\File $fob File to attach * * @return \StdClass Pointer to the attachment * * @throws \Exception */ public function addAttachment(\Concrete\Core\File\File $fob) { // Get file version. $fv = $fob->getVersion(); // Get file data. $mimetype = $fv->getMimeType(); $filename = $fv->getFilename(); $resource = $fob->getFileResource(); $content = $resource->read(); // Create attachment. $mp = new MimePart($content); $mp->type = $mimetype; $mp->disposition = Mime::DISPOSITION_ATTACHMENT; $mp->encoding = Mime::ENCODING_BASE64; $mp->filename = $filename; // Add mimepart to attachments. $this->attachments[] = $mp; }