Add email attachment.

@param string $name      The name of the file.
@param string $data      The contents.
@param string $mimeType  The specify MIME type.
@param string $contentId Content ID.

@return void
551066
public function addAttachmentFromData($name, $data, $mimeType = 'application/octet-stream', $contentId = null)
    {
        $this->_attachments[] = array(
            'name' => $name,
            'mimeType' => $mimeType,
            'data' => $data,
            'contentId' => $contentId
        );
    }
789635
public static MimeBodyPart newHtmlAttachmentBodyPart( URL contentUrl, String contentId )
    throws MessagingException
  {
    MimeBodyPart mimeBodyPart = new MimeBodyPart();
    mimeBodyPart.setDataHandler(new DataHandler(contentUrl));
    if( contentId != null ) {
      mimeBodyPart.setHeader("Content-ID", contentId);
    }
    return mimeBodyPart;
  }
1169500
public SoapServerFaultResponseActionBuilder attachment(String contentId, String contentType, Resource contentResource, Charset charset) {
        SoapAttachment attachment = new SoapAttachment();
        attachment.setContentId(contentId);
        attachment.setContentType(contentType);

        try {
            attachment.setContent(FileUtils.readToString(contentResource, charset));
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to read attachment resource", e);
        }

        getAction().getAttachments().add(attachment);

        return this;
    }
973745
public function addContent(string $cid, string $content, string $name = null, string $mimeType = null): void
    {
        $embed = new ContentEmbed();
        $embed->cid = $cid;
        $embed->content = $content;
        if ($name !== null) {
            $embed->name = $name;
        }
        if ($mimeType !== null) {
            $embed->mimeType = $mimeType;
        }
        $this->set($embed);
    }
929032
public function addAttachment($name, $MIMEType, $content)
    {
        if (isset($this->attachments[$name])) {
            throw new Exception("The attachment identified by '{$name}' has already been set.");
        } else {
            $this->attachments[$name] = array("type" => $MIMEType, "content" => $content);
            $this->hasAttachments = true;
        }
    }
775558
public function makeFromFileInfo(SplFileInfo $data, $name = null, $mimeType = null)
    {
        $file = new SplFileInfoStorableFile;
        $file->setData($data);

        if (null !== $mimeType) {
            $file->setMimeType($mimeType);
        } else {
            $file->setMimeType(
                $this->mimeTypeHelper->guessMimeTypeForPath($data->getRealPath())
            );
        }

        if (empty($name)) {
            $name = pathinfo($data->getRealPath(), PATHINFO_BASENAME);
        }

        if (null !== $name) {
            $file->setName($name);
        }

        return $this->getReturnPreparedFile($file);
    }
211037
public function addFile($file, $name = 'attachment', $mime = Mime::TXT) {
        $this->_fileTransfert = 'multipart/mixed';
        $this->_hasAttachment = true;

        if (file_exists($file)) {
            $data = file_get_contents($file);

            if ($name == self::ATTACHMENT) {
                $name = $name . uniqid();
            }

            if (isset($this->_attachments[$name])) {
                $name = $name . uniqid();
            }

            $this->_attachments[$name] = [chunk_split(base64_encode($data), $mime)];
        }
    }
1325133
public function uploadString($name, $content, $contentType = 'text/plain')
    {
        $fileName = $this->path . '/' . $this->getFilePathAndUniquePrefix() . $name;

        if ($contentType === 'application/json') {
            $content = Json::prettyPrint($content);
        }

        (new Filesystem)->dumpFile($fileName, $content);

        return $fileName;
    }
1283552
public function attachment($file, $name = null, $mime = null) {

		if(true === is_string($file)) {
			$file = new File($file);
		}

		if(false === $file instanceof File) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or sFire\System\File, "%s" given', __METHOD__, gettype($file)), E_USER_ERROR);
		}

		if(false === $file -> isReadable()) {
			return trigger_error(sprintf('Argument 1 passed to %s() must existing and readable file', __METHOD__), E_USER_ERROR);
		}

		if(null !== $name && false === is_string($name)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($name)), E_USER_ERROR);
		}

		if(null !== $mime && false === is_string($mime)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($mime)), E_USER_ERROR);
		}

		if(false === isset($this -> headers['files'])) {
			$this -> headers['files'] = [];
		}

		$name = null !== $name ? $name : $file -> entity() -> getBasename();
		$mime = null !== $mime ? $mime : $file -> getMime();

		$this -> headers['files'][] = (object) ['file' => $file, 'name' => $name, 'mime' => $mime];

		return $this;
	}
965752
public function update($path, $content, $mimeType = null)
    {
       return $this->getFile($path)->update($content, $mimeType);
    }
1304055
public function readString($data, $mimeType = null)
    {
        if (null === $mimeType) {
            $mimeType = ContentType::JSON()->primaryMimeType();
        }

        return $this->read($this->uriFactory()->fromData($data, $mimeType), $mimeType);
    }
1283587
public function makeFromAny($data, $name = null, $mimeType = null)
    {
        // If the data is already a storable file, return it as-is.
        if ($data instanceof StorableFileInterface) {
            return $this->getReturnPreparedFile($data);
        }


        if (null === $name && is_a($data, \Symfony\Component\HttpFoundation\File\UploadedFile::class)) {
            /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $data */
            $name = $data->getClientOriginalName();
        }

        if ($data instanceof SplFileInfo) {
            return $this->makeFromFileInfo($data, $name, $mimeType);
        }


        // Fallback: expect raw or string data, and attempt to interpret it.
        if (is_string($data)) {
            $data = new RawContent($data);
        }

        if ( ! ($data instanceof RawContentInterface)) {
            throw new UnexpectedValueException('Could not interpret given data, string value expected');
        }

        return $this->interpretFromRawContent($data, $name, $mimeType);
    }
845497
public function addFile(string $cid, string $filename, string $name = null, string $mimeType = null): void
    {
        $embed = new FileEmbed();
        $embed->cid = $cid;
        $embed->filename = $filename;
        if ($name !== null) {
            $embed->name = $name;
        }
        if ($mimeType !== null) {
            $embed->mimeType = $mimeType;
        }
        $this->set($embed);
    }
1213336
public function add(string $email, string $name = null): void
    {
        $bccRecipient = $this->make();
        $bccRecipient->email = $email;
        if ($name !== null) {
            $bccRecipient->name = $name;
        }
        $this->set($bccRecipient);
    }
227683
public static function download($name = null, $contentLength = 0)
    {
        if ($name) {
            $name = '; filename="' . strtr($name, '"', '-') . '"';
        } else {
            $name = '';
        }

        self::putHeader('Content-Transfer-Encoding', 'Binary');
        self::putHeader('Content-Disposition', 'attachment' . $name);

        if ($contentLength > 0) {
            self::putHeader('Content-Length', $contentLength);
        }
    }
252487
public function setContentType( $mimeType, $charset = 'UTF-8', $format = self::FORMAT_FIXED )
	{
		$value	= trim( $mimeType ).'; charset='.trim( $charset ).'; format='.trim( $format );
		$this->headers->setFieldPair( 'Content-Type', $value );
	}
654913
public void setMimeattach(String strMimeattach, String fileName, String type, String disposition, String contentID, boolean removeAfterSend) throws PageException {
	Resource file = ResourceUtil.toResourceNotExisting(pageContext, strMimeattach);
	pageContext.getConfig().getSecurityManager().checkFileLocation(file);
	if (!file.exists()) throw new ApplicationException("can't attach file " + strMimeattach + ", this file doesn't exist");

	smtp.addAttachment(file, fileName, type, disposition, contentID, removeAfterSend);

    }