MailManager
class MailManager implements Factory mixin Mailer
Traits
Hosts must declare a protected array $poolableDrivers containing their default poolable drivers.
Constants
| protected TRANSPORT_PRESENTATION_KEYS |
Mailer-level keys that do not affect built-in transport construction. |
Properties
| protected Closure> | $releaseCallbacks | from HasPoolProxy | |
| protected Repository | $config | The config instance. |
|
| protected array | $mailers | The array of resolved mailers. |
|
| protected array | $customCreators | The registered custom driver creators. |
|
| protected array | $poolableDrivers | The array of drivers which will be wrapped as pool proxies. |
Methods
Create a pool proxy for an immutable definition.
Build a namespaced pool definition for a pooled resource.
Get the shared object-pool factory.
Get the release callback for a pooled driver.
Add a driver to the poolable-driver list.
Remove a driver from the poolable-driver list.
Set the poolable-driver list.
Create a new transport instance.
Create a pooled or direct transport for a mailer.
Resolve whether and how a mail transport should be pooled.
Create a transport from its fully resolved construction config.
Resolve the exact configuration consumed to construct a transport.
Resolve Mailgun's credential and HTTP-client construction config.
Resolve a composite transport's ordered child construction configs.
Extract HTTP-client options that affect transport construction.
Create an instance of the Symfony SMTP Transport driver.
Configure the additional SMTP driver options.
Create an instance of the Symfony Sendmail Transport driver.
Create an instance of the Symfony Amazon SES V2 Transport driver.
Add the SES credentials to the configuration array.
Create an instance of the Resend Transport driver.
Create an instance of the Cloudflare Transport driver.
Create an instance of the Symfony Mail Transport driver.
Create an instance of the Symfony Mailgun Transport driver.
Create an instance of the Symfony Postmark Transport driver.
Create an instance of the Symfony Failover Transport driver.
Create an instance of the Symfony Roundrobin Transport driver.
Create an instance of supplied class extending the Symfony Roundrobin Transport driver.
Create an instance of the Log Transport driver.
Create an instance of the Array Transport Driver.
Get a configured Symfony HTTP client instance.
Set a global address on the mailer by type.
Get the mail connection configuration.
Get the default mail driver name.
Set the default mail driver name.
Disconnect the given mailer and close its shared transport pool.
Get the application instance used by the manager.
Forget all of the resolved mailer instances.
Dynamically call the default driver instance.
Details
in
HasPoolProxy at line 28
protected mixed
createPoolProxy(string $driver, Closure $createCallback, PoolDefinition $definition, string $proxyClass)
Create a pool proxy for an immutable definition.
in
HasPoolProxy at line 49
protected PoolDefinition
poolDefinition(string $resource, array $poolConfig, array $fingerprintSource)
Build a namespaced pool definition for a pooled resource.
at line 692
protected Factory
poolFactory()
Get the shared object-pool factory.
in
HasPoolProxy at line 75
HasPoolProxy
setReleaseCallback(string $driver, Closure $callback)
Set the release callback for a pooled driver.
The callback persists on the shared manager for the worker lifetime and is captured by every subsequently created proxy for the driver.
in
HasPoolProxy at line 86
Closure|null
getReleaseCallback(string $driver)
Get the release callback for a pooled driver.
in
HasPoolProxy at line 98
HasPoolProxy
addPoolableDriver(string $driver)
Add a driver to the poolable-driver list.
The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.
in
HasPoolProxy at line 115
HasPoolProxy
removePoolableDriver(string $driver)
Remove a driver from the poolable-driver list.
The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.
in
HasPoolProxy at line 133
array
getPoolableDrivers()
Get the poolable-driver list.
in
HasPoolProxy at line 145
HasPoolProxy
setPoolableDrivers(array $poolableDrivers)
Set the poolable-driver list.
The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.
at line 94
__construct(Container $app)
Create a new Mail manager instance.
at line 103
Mailer
mailer(UnitEnum|string|null $name = null)
Get a mailer instance by name.
at line 119
Mailer
driver(UnitEnum|string|null $driver = null)
Get a mailer driver instance.
at line 127
protected Mailer
get(string $name)
Attempt to get the mailer from the local cache.
at line 137
protected Mailer
resolve(string $name)
Resolve the given mailer.
at line 176
Mailer
build(array $config)
Build a new mailer instance.
at line 204
TransportInterface
createSymfonyTransport(array $config)
Create a new transport instance.
at line 216
protected TransportInterface
createMailerTransport(array $config, array $mailerStack = [], bool $poolByDefault = false)
Create a pooled or direct transport for a mailer.
at line 240
protected array|null
transportPoolConfig(string $transport, array $config, bool $poolByDefault)
Resolve whether and how a mail transport should be pooled.
at line 270
protected TransportInterface
createSymfonyTransportFromConstructionConfig(array $config)
Create a transport from its fully resolved construction config.
at line 289
protected array
transportConstructionConfig(array $config, array $mailerStack = [])
Resolve the exact configuration consumed to construct a transport.
at line 358
protected array
mailgunTransportConstructionConfig(array $config)
Resolve Mailgun's credential and HTTP-client construction config.
at line 380
protected array
compositeTransportConstructionConfig(string $transport, array $config, array $mailerStack)
Resolve a composite transport's ordered child construction configs.
at line 422
protected array
httpClientConstructionConfig(array $config)
Extract HTTP-client options that affect transport construction.
at line 430
protected EsmtpTransport
createSmtpTransport(array $config)
Create an instance of the Symfony SMTP Transport driver.
at line 456
protected EsmtpTransport
configureSmtpTransport(EsmtpTransport $transport, array $config)
Configure the additional SMTP driver options.
at line 476
protected SendmailTransport
createSendmailTransport(array $config)
Create an instance of the Symfony Sendmail Transport driver.
at line 486
protected SesV2Transport
createSesV2Transport(array $config)
Create an instance of the Symfony Amazon SES V2 Transport driver.
at line 506
protected array
addSesCredentials(array $config)
Add the SES credentials to the configuration array.
at line 522
protected ResendTransport
createResendTransport(array $config)
Create an instance of the Resend Transport driver.
at line 530
protected CloudflareTransport
createCloudflareTransport(array $config)
Create an instance of the Cloudflare Transport driver.
at line 542
protected SendmailTransport
createMailTransport()
Create an instance of the Symfony Mail Transport driver.
at line 550
protected TransportInterface
createMailgunTransport(array $config)
Create an instance of the Symfony Mailgun Transport driver.
at line 565
protected PostmarkApiTransport
createPostmarkTransport(array $config)
Create an instance of the Symfony Postmark Transport driver.
at line 586
protected FailoverTransport
createFailoverTransport(array $config)
Create an instance of the Symfony Failover Transport driver.
at line 594
protected RoundRobinTransport
createRoundrobinTransport(array $config)
Create an instance of the Symfony Roundrobin Transport driver.
at line 609
protected RoundRobinTransport
createRoundrobinTransportOfClass(array $config, string $class)
Create an instance of supplied class extending the Symfony Roundrobin Transport driver.
at line 623
protected LogTransport
createLogTransport(array $config)
Create an instance of the Log Transport driver.
at line 637
protected ArrayTransport
createArrayTransport()
Create an instance of the Array Transport Driver.
at line 645
protected HttpClientInterface|null
getHttpClient(array $config)
Get a configured Symfony HTTP client instance.
at line 663
protected void
setGlobalAddress(Mailer $mailer, array $config, string $type)
Set a global address on the mailer by type.
at line 675
protected array|null
getConfig(string $name)
Get the mail connection configuration.
at line 700
string
getDefaultDriver()
Get the default mail driver name.
at line 710
void
setDefaultDriver(UnitEnum|string $name)
Set the default mail driver name.
Mutates process-global config; per-request use races across coroutines.
at line 724
void
purge(UnitEnum|string|null $name = null)
Disconnect the given mailer and close its shared transport pool.
Use this to recover broken pooled resources. Other mailers sharing the pool transparently acquire a fresh pool on their next operation.
at line 776
MailManager
extend(string $driver, Closure $callback, bool $poolable = false)
Register a custom driver creator Closure.
The callback persists in the singleton's customCreators array (and the poolable list if $poolable is true) for the worker lifetime and applies to every subsequent transport resolution.
at line 791
Container
getApplication()
Get the application instance used by the manager.
at line 805
MailManager
setApplication(Container $app)
Set the application instance used by the manager.
Swaps the singleton's container and configuration references without rebuilding resolved mailers; per-request use races across coroutines and breaks every concurrent mail send.
at line 822
MailManager
forgetMailers()
Forget all of the resolved mailer instances.
This is cache-only: pooled transports remain shared resources until purged or reclaimed by their idle TTL.
at line 833
mixed
__call(string $method, array $parameters)
Dynamically call the default driver instance.