Install the Mailing and Notifications feature
Edit on GitHubThe following feature integration guide expects the basic feature to be in place. This guide describes all the required steps in order to integrate a mailing provider into your project.
Install feature core
Follow the steps below to install the feature core.
Prerequisites
Install the required features:
NAME | VERSION | INSTALLATION GUIDE |
---|---|---|
Spryker Core | 202507.0 | Install the Spryker Core feature |
1) Install the required modules
Install the required modules using Composer:
composer require spryker/symfony-mailer:^1.1.0 --update-with-dependencies
Make sure that the following modules have been installed:
MODULE | EXPECTED DIRECTORY |
---|---|
SymfonyMailer | spryker/symfony-mailer |
2) Set up transfer objects
Generate transfers:
console transfer:generate
Make sure the following changes have been applied in transfer objects:
TRANSFER | TYPE | EVENT | PATH |
---|---|---|---|
Mail.subjectTranslationParameters | property | added | src/Generated/Shared/Transfer/MailTransfer |
MailRecipient.nameTranslationParameters | property | added | src/Generated/Shared/Transfer/MailRecipientTransfer |
MailSender.nameTranslationParameters | property | added | src/Generated/Shared/Transfer/MailSenderTransfer |
3) Set up behavior
Activate the following plugins:
PLUGIN | SPECIFICATION | NAMESPACE |
---|---|---|
SymfonyMailerProviderPlugin | Provides mail sending using SymfonyMailer component. |
Spryker\Zed\SymfonyMailer\Communication\Plugin\Mail |
src/Pyz/Zed/Mail/MailDependencyProvider.php
<?php
namespace Pyz\Zed\Mail;
use Spryker\Zed\Kernel\Container;
use Spryker\Zed\Mail\Business\Model\Provider\MailProviderCollectionAddInterface;
use Spryker\Zed\Mail\MailConfig;
use Spryker\Zed\Mail\MailDependencyProvider as SprykerMailDependencyProvider;
use Spryker\Zed\SymfonyMailer\Communication\Plugin\Mail\SymfonyMailerProviderPlugin;
class MailDependencyProvider extends SprykerMailDependencyProvider
{
protected function extendMailProviderCollection(Container $container): Container
{
$container->extend(static::MAIL_PROVIDER_COLLECTION, function (MailProviderCollectionAddInterface $mailProviderCollection) {
$mailProviderCollection
->addProvider(new SymfonyMailerProviderPlugin(), [
MailConfig::MAIL_TYPE_ALL,
]);
return $mailProviderCollection;
});
return $container;
}
}
To verify that everything is set up correctly and send an email, see How to create and register MailTypeBuilderPlugin.
Migrate from SwiftMailer to Symfony Mailer
If your application is using SwiftMailer, the following variables have the values:
- SPRYKER_SMTP_PORT = 587
- SPRYKER_SMTP_ENCRYPTION=‘tls’
To migrate to Symfony Mailer, follow the steps:
- Force the port for SMTP to 465 and release this change with the migration release:
$config[SymfonyMailerConstants::SMTP_PORT] = '465';
-
Create a support ticket to change
SPRYKER_SMTP_PORT
to 465. -
Revert configuration to the previous state to use a port from the env variable:
$config[SymfonyMailerConstants::SMTP_PORT] = getenv('SPRYKER_SMTP_PORT') ?: null;
- Redeploy the application.
Thank you!
For submitting the form