/** * Embeds an attachment into the message and returns its reference. * * @param string $data Binary or string * @param string $mimetype Mime type of the attachment (e.g. "text/plain", "application/octet-stream", etc.) * @param string|null $filename Name of the attached file * @return string Content ID for referencing the attachment in the HTML body */ public function embedAttachment($data, $mimetype, $filename) { $part = \Swift_EmbeddedFile::newInstance($data, $mimetype, $filename); return $this->object->embed($part); }
/** * @inheritdoc */ public function embedContent($content, array $options = []) { $embedFile = \Swift_EmbeddedFile::newInstance($content); if (!empty($options['fileName'])) { $embedFile->setFilename($options['fileName']); } if (!empty($options['contentType'])) { $embedFile->setContentType($options['contentType']); } return $this->getSwiftMessage()->embed($embedFile); }
/** * Generates a CID for a data by which the data can be embedded into the body of a message. * * The same CID can be used to embed a data in more than one place. * * For example, an image for which a CID was generated and put into `$cid` variable can be embedded into a message * with HTML type of body by `<img src="' . $cid . '" alt="Title" />`. * * @param data $data The data to be embedded. * @param string $filename The filename to be associated with the embedded data. * @param string $type The MIME type of the data's contents. * * @return CUStringObject The embeddable CID of the data. */ public function embeddableCidForData($data, $filename, $type) { assert('is_cstring($data) && is_cstring($filename) && is_cstring($type)', vs(isset($this), get_defined_vars())); assert('isset($this->m_swiftMessage)', vs(isset($this), get_defined_vars())); $data = _from_oop_tp($data); $embeddedFile = Swift_EmbeddedFile::newInstance($data, $filename, $type); return $this->m_swiftMessage->embed($embeddedFile); }
protected function _createEmbeddedFile() { return Swift_EmbeddedFile::newInstance(); }
/** * Embed a file from dynamic content * * @param string $data * @param string $fileName * @param string $contentType * @return string An identifier of the embed file */ function embedData($data, $fileName = null, $contentType = null) { $file = Swift_EmbeddedFile::newInstance($data, $fileName, $contentType); return $this->embed($file); }