Browse Source

Fixes #63: Added ability to specify the disposition of an attachment by supplying a `setDisposition` value when embedding content in a message

tags/2.1.2
Corey Watts 6 years ago committed by Alexander Makarov
parent
commit
4faba373f9
  1. 2
      CHANGELOG.md
  2. 3
      src/Message.php
  3. 4
      tests/MessageTest.php

2
CHANGELOG.md

@ -4,7 +4,7 @@ Yii Framework 2 swiftmailer extension Change Log
2.1.2 under development 2.1.2 under development
----------------------- -----------------------
- no changes in this release. - Enh #63: Added ability to specify the disposition of an attachment by supplying a `setDisposition` value when embedding content in a message (CorWatts)
2.1.1 April 25, 2018 2.1.1 April 25, 2018

3
src/Message.php

@ -290,6 +290,9 @@ class Message extends BaseMessage
if (!empty($options['contentType'])) { if (!empty($options['contentType'])) {
$attachment->setContentType($options['contentType']); $attachment->setContentType($options['contentType']);
} }
if (!empty($options['setDisposition'])) {
$attachment->setDisposition($options['setDisposition']);
}
$this->getSwiftMessage()->attach($attachment); $this->getSwiftMessage()->attach($attachment);
return $this; return $this;

4
tests/MessageTest.php

@ -356,13 +356,15 @@ U41eAdnQ3dDGzUNedIJkSh6Z0A4VMZIEOag9hPNYqQXZBQgfobvPKw==
$message->setTextBody('Yii Swift Create Attachment Test body'); $message->setTextBody('Yii Swift Create Attachment Test body');
$fileName = 'test.txt'; $fileName = 'test.txt';
$fileContent = 'Test attachment content'; $fileContent = 'Test attachment content';
$message->attachContent($fileContent, ['fileName' => $fileName]); $message->attachContent($fileContent, ['fileName' => $fileName, 'contentType' => 'image/png', 'setDisposition' => 'inline']);
$this->assertTrue($message->send()); $this->assertTrue($message->send());
$attachment = $this->getAttachment($message); $attachment = $this->getAttachment($message);
$this->assertTrue(is_object($attachment), 'No attachment found!'); $this->assertTrue(is_object($attachment), 'No attachment found!');
$this->assertEquals($fileName, $attachment->getFilename(), 'Invalid file name!'); $this->assertEquals($fileName, $attachment->getFilename(), 'Invalid file name!');
$this->assertEquals('image/png', $attachment->getContentType(), 'Invalid content type!');
$this->assertEquals('inline', $attachment->getDisposition(), 'Invalid disposition!');
} }
/** /**

Loading…
Cancel
Save