Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Showing 3 changed files with 74 additions and 0 deletions.
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Changelog

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.5.2 - TBD

### Added

- [#2](https://github.com/zendframework/zend-log/pull/2) adds
the ability to specify the mail transport via the configuration options for a
mail log writer, using the same format supported by
`Zend\Mail\Transport\Factory::create()`; as an example:

```php
$writer = new MailWriter([
'mail' => [
// message options
],
'transport' => [
'type' => 'smtp',
'options' => [
'host' => 'localhost',
],
],
]);
```

### Deprecated

- Nothing.

### Removed

- [#43](https://github.com/zendframework/zend-diactoros/pull/43) removed both
`ServerRequestFactory::marshalUri()` and `ServerRequestFactory::marshalHostAndPort()`,
which were deprecated prior to the 1.0 release.

### Fixed

- Nothing.
3 changes: 3 additions & 0 deletions src/Writer/Mail.php
Original file line number Diff line number Diff line change
@@ -90,6 +90,9 @@ public function __construct($mail, Transport\TransportInterface $transport = nul
if (is_array($mail)) {
$mail = MailMessageFactory::getInstance($mail);
}
if (is_array($transport)) {
$transport = Transport\Factory::create($transport);
}
}

// Ensure we have a valid mail message
31 changes: 31 additions & 0 deletions test/Writer/MailTest.php
Original file line number Diff line number Diff line change
@@ -128,4 +128,35 @@ public function testConstructWithMailAsArrayOptions()

$this->assertAttributeInstanceOf('Zend\Mail\Message', 'mail', $writer);
}

public function testConstructWithMailTransportAsArrayOptions()
{
$messageOptions = [
'encoding' => 'UTF-8',
'from' => 'matthew@example.com',
'to' => 'zf-devteam@example.com',
'subject' => 'subject',
'body' => 'body',
];

$transportOptions = [
'type' => 'smtp',
'options' => [
'host' => 'test.dev',
'connection_class' => 'login',
'connection_config' => [
'username' => 'foo',
'smtp_password' => 'bar',
'ssl' => 'tls'
]
]
];

$writer = new MailWriter([
'mail' => $messageOptions,
'transport' => $transportOptions,
]);

$this->assertAttributeInstanceOf('Zend\Mail\Transport\Smtp', 'transport', $writer);
}
}

0 comments on commit 587013c

Please sign in to comment.