Back to Blog
Core Components

Replacing laminas-mail with Symfony mailer in dot-mail

What prompted the change

According to the Laminas Technical Steering Committee minutes of 2023-12-04, laminas/laminas-mail was going to be abandoned: nobody was available to maintain it, and alternatives already existed in the ecosystem:

Purpose Package
Interacting with IMAP ddeboer/imap
Parsing MIME messages zbateson/mail-mime-parser
Sending mail symfony/mailer

How Dotkernel handles the issue

The Dotkernel team opted to replace laminas/laminas-mail in the dotkernel/dot-mail package. This meant revising the code, including configuration files, while trying to have minimal impact on existing projects: the calls to send mail remain the same, even though some lesser-used functionality like mime and imap is lost.

Technical approach

The switch from laminas/laminas-mail to symfony/mailer in dotkernel/dot-mail is covered across these pull requests:

Function definition changes are not covered in the article.

The mail.global.php configuration file was revised to remove features that are no longer available and to make it easier to configure. The mail transport can be any class implementing Symfony\Component\Mailer\Transport\TransportInterface; standard aliases are sendmail (Symfony\Component\Mailer\Transport\SendmailTransport) and esmtp (Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport), defaulting to sendmail. smtp_options are used only when the esmtp adapter is used, and there is a log option to log sent emails.

Use ONE of the below transporters, based on your server configuration:

'transport' => 'sendmail',

OR

'transport' => 'esmtp',

Sendmail is set as the default mail transport.

How to update dotkernel/dot-mail from version 3 or 4 to version 5

  1. Download the new mail configuration file.
  2. Add the values you configured for your project, focusing on transport, message_options and smtp_options, then replace your old configuration file.
  3. In your composer.json, update to "dotkernel/dot-mail": "^5.0.0" and run composer update.

At this point, mime and imap related functionality is removed.

Frequently Asked Questions

Why was laminas/laminas-mail replaced? +

The Laminas Technical Steering Committee decided on 2023-12-04 that laminas/laminas-mail would be abandoned because there was nobody to maintain it, and several alternatives were already available in the ecosystem.

What alternatives were identified for the abandoned laminas-mail package? +

The alternatives mentioned are ddeboer/imap for interacting with IMAP, zbateson/mail-mime-parser for parsing MIME messages, and symfony/mailer for sending mail.

How did Dotkernel handle the removal of laminas-mail in dot-mail? +

The Dotkernel team replaced laminas/laminas-mail with symfony/mailer inside the dotkernel/dot-mail package, revising the code and configuration files while aiming for minimal impact on existing projects, so the calls used to send mail stay the same, even though some lesser-used functionality like mime and imap is lost.

Which mail transport does dot-mail use by default? +

The revised mail.global.php configuration defaults the transport to sendmail. You should use ONE of the transporters, either 'transport' => 'sendmail' or 'transport' => 'esmtp', based on your server configuration; Sendmail was set as the default.

How do I update dotkernel/dot-mail from version 3 or 4 to version 5? +

Download the new mail.global.php.dist configuration file, add the values you configured for your project (focusing on transport, message_options and smtp_options) to replace your old configuration file, then update "dotkernel/dot-mail" to "^5.0.0" in composer.json and run composer update.

What functionality is lost after switching to symfony/mailer? +

At the time of the article, mime and imap related functionality is removed from dot-mail as a result of the switch.