composer require weew/app-swift-mailer
This package integrates the swiftmailer/swiftmailer library into the weew/app package.
To make SwiftMailer available inside your application, simply register SwiftMailerProvider
on the kernel.
$app->getKernel()->addProviders([
SwiftMailerProvider::class
]);
You can retrieve a specific mailer by config name like this:
$swiftMailerManager = $app->getContainer()->get(ISwiftMailerManager::class);
// returns the default mailer
$swiftMailerManager->getMailer();
// returns a mailer using the specific config
$swiftMailerManager->getMailer('config1');
Currently supported transports are null
, sendmail
, smtp
. This is how your configuration might look like:
swift_mailer:
transports:
# this is the default transport that is used in case no
# mailer config name has been specified
default: "{swift_mailer.transports.config2}"
config1:
type: smtp
# server settings
host: localhost
port: 25
security: tls
# server username and password
username:
password:
config2:
type: sendmail
# override for the used sendmail command
command: