Navigation

Mail

Sending mail is a standard web application task. There are many cases where an action triggers an email to be sent. These actions can be newsletter subscriptions, order placement, refunds, customer account registration, etc.

The Mail module helps you to create emails to be sent. To send an email you need to create a MailTransfer and pass it to the MailFacade::handleMail() method. The Mail module will handle sending the email.

MailFacade::handleMail() uses the email provider that you define for the project and each provider behaves differently. One takes a fully rendered template and sends it, one just will receive a request with query params and another one only works with a well formatted JSON. There are many ways Mail Providers do their job. Therefore the Mail module is suited to work easily with a wide range of providers.

To get started a simple provider has been included. The (default) provider uses SwiftMailer. The implementation uses the same view behavior as Yves and Zed. The default provider renders the defined templates and sends them. Override functionality for overriding templates and translations are also available in this module.

Some Spryker Commerce OS modules already make use of the Mail module. To make sure the Mail modulehandles the mail for these other modules, register them in the Mail module before allowing emails to be handled.

See also: