Author: Chris Corbyn
Inheritance: extends Swift_OutputByteStream
Beispiel #1
0
 /**
  * Set the file that this attachment is for.
  *
  * @param Swift_FileStream $file
  * @param string           $contentType optional
  *
  * @return Swift_Mime_Attachment
  */
 public function setFile(Swift_FileStream $file, $contentType = null)
 {
     $this->setFilename(basename($file->getPath()));
     $this->setBody($file, $contentType);
     if (!isset($contentType)) {
         $extension = strtolower(substr($file->getPath(), strrpos($file->getPath(), '.') + 1));
         if (array_key_exists($extension, $this->_mimeTypes)) {
             $this->setContentType($this->_mimeTypes[$extension]);
         }
     }
     return $this;
 }
 /**
  * @param Swift_FileStream      $outputStream
  * @param Swift_InputByteStream $is
  *
  * @throws Swift_IoException
  */
 protected function messageStreamToEncryptedByteStream(Swift_FileStream $outputStream, Swift_InputByteStream $is)
 {
     $encryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream();
     if (!openssl_pkcs7_encrypt($outputStream->getPath(), $encryptedMessageStream->getPath(), $this->encryptCert, array(), 0, $this->encryptCipher)) {
         throw new Swift_IoException(sprintf('Failed to encrypt S/Mime message. Error: "%s".', openssl_error_string()));
     }
     $this->copyFromOpenSSLOutput($encryptedMessageStream, $is);
 }