MailerFactory
class \
Creates mailers for named mail profiles.
Inject this factory instead of the MailerInterface when an email must not be sent through the globally configured transport, for example when newsletters and transactional emails are delivered by different providers.
Mailers are kept per profile, so an established SMTP connection is reused for all emails sent through the same profile within one request.
Attributes
- #[Autoconfigure]
- $public: true
Table of Contents
Methods
- __construct() : mixed
- getMailer() : MailerInterface
- Returns the mailer of the given profile, or the globally configured mailer without one.
Methods
__construct()
public
__construct(MailProfileResolver $mailProfileResolver, TransportFactory $transportFactory, EventDispatcherInterface $eventDispatcher, MailerInterface $mailer) : mixed
Parameters
- $mailProfileResolver : MailProfileResolver
- $transportFactory : TransportFactory
- $eventDispatcher : EventDispatcherInterface
- $mailer : MailerInterface
getMailer()
Returns the mailer of the given profile, or the globally configured mailer without one.
public
getMailer([string|null $profileName = null ]) : MailerInterface
Parameters
- $profileName : string|null = null