Ejemplo n.º 1
0
 /**
  * Upload an attachment to Elastic Email so it can be reused when an email is sent
  *
  * @link   http://elasticemail.com/api-documentation/attachments-upload
  * @param  Part $attachment
  * @return int The attachment id
  */
 public function uploadAttachment(Part $attachment)
 {
     $request = $this->prepareHttpClient('/attachments/upload', array('file' => $attachment->filename))->setMethod(HttpRequest::METHOD_PUT)->setRawBody($attachment->getRawContent())->getRequest();
     // Elastic Email handles the content type of the message itself. Based on the extension of
     // the file, Elastic Email determines the content type. The attachment must be uploaded to
     // the server with always the application/x-www-form-urlencoded content type.
     //
     // More information: http://support.elasticemail.com/discussions/questions/1486-how-to-set-content-type-of-an-attachment
     $request->getHeaders()->addHeaderLine('Content-Type', 'application/x-www-form-urlencoded')->addHeaderLine('Content-Length', strlen($attachment->getRawContent()));
     $response = $this->client->send($request);
     return $this->parseResponse($response);
 }
Ejemplo n.º 2
0
 /**
  * @group ZF-1491
  */
 public function testGetRawContentFromPart()
 {
     $this->assertEquals($this->testText, $this->part->getRawContent());
 }