Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support email headers #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions DotBlue/Mandrill/AbstractMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,24 @@ public function removeImage(IAttachment $toBeRemoved)

/** @var string[] */
public $metadata = [];


/**
* @return []
*/
public function getHeaders()
{
return $this->headers;
}


/**
* @param string $header
* @param string $value
*/
public function addHeader($header, $value)
{
$this->headers[$header] = $value;
}

}
3 changes: 3 additions & 0 deletions DotBlue/Mandrill/Exporters/MessageExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ private function exportMessage(\DotBlue\Mandrill\IBasicMessage $message)
// Attachments
'attachments' => $this->exportAttachments($message->getAttachments()),
'images' => $this->exportAttachments($message->getImages()),

// Headers
'headers' => $message->getHeaders(),
],
]);
}
Expand Down
6 changes: 6 additions & 0 deletions DotBlue/Mandrill/IBasicMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ function getMergeVars();
function getAttachments();


/**
* @return []
*/
function getHeaders();


/**
* @return IAttachment[]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ class MessageExporterTest extends \Tester\TestCase

'inline_css' => TRUE,
'preserve_recipients' => FALSE,

'headers' => [],
],
'async' => TRUE,
'ip_pool' => 'IP pool',
Expand Down
13 changes: 13 additions & 0 deletions tests/DotBlueTests/Mandrill/MessageTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ class MessageTest extends \Tester\TestCase
Assert::same('<b>HTML!</b>', $message->getHtml());
Assert::same('HTML!', $message->getText());
}


public function testHeaders()
{
$message = new Message('dummy');
$message->addHeader('header1', 'value1');
$message->addHeader('header2', 'value2');

Assert::same([
'header1' => 'value1',
'header2' => 'value2',
], $message->getHeaders());
}
}

(new MessageTest())->run();
13 changes: 13 additions & 0 deletions tests/DotBlueTests/Mandrill/TemplateMessageTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ class TemplateMessageTest extends \Tester\TestCase
'secondRegion' => 'yabadabadooo',
], $message->getEditableRegions());
}


public function testHeaders()
{
$message = new TemplateMessage('dummy');
$message->addHeader('header1', 'value1');
$message->addHeader('header2', 'value2');

Assert::same([
'header1' => 'value1',
'header2' => 'value2',
], $message->getHeaders());
}
}

(new TemplateMessageTest())->run();