DotKernel mail component based on laminas-mail

3.2.1 2021-09-24 10:41 UTC


DotKernel mail component based on laminas-mail

OSS Lifecycle

GitHub issues GitHub stars GitHub license

Testing if an e-mail message is valid

After sending an e-mail you can check if the message was valid or not. The $this->mailService->send()->isValid() method call will return a boolean value. If the returned result is true, the e-mail was valid, otherwise the e-mail was invalid. In case your e-mail was invalid, you can check for any errors using $this->mailService->send()->getMessage().

Using the below logic will let you determinate if a message was valid or not and log it.

The implementor can write it's own custom error log logic.

$result = $this->mailService->send();
if (! $result->isValid()) {
    //log the error

Note : Invalid e-mail messages will not be sent.

Logging outgoing emails

Optionally, you can keep a log of each successfully sent email. This might be useful when you need to know if/when a specific email has been sent out to a recipient.

Logs are stored in the following format: [YYYY-MM-DD HH:MM:SS]: {"subject":"Test subject","to":["Test Account <>"],"cc":[],"bcc":[]}.

By default, this feature is disabled.

In order to enable it, make sure that your config/autoload/mail.local.php has the below log configuration under the dot_mail key:


return [
    'dot_mail' => [
        'log' => [
            'sent' => getcwd() . '/log/mail/sent.log'

To disable it again, set the value of sent to null.