class Mailer
@author Fabien Potencier <fabien@symfony.com>
Hierarchy
- class \Symfony\Component\Mailer\Mailer implements \Symfony\Component\Mailer\MailerInterface
Expanded class hierarchy of Mailer
1 file declares its use of Mailer
- SymfonyMailer.php in core/
lib/ Drupal/ Core/ Mail/ Plugin/ Mail/ SymfonyMailer.php
1 string reference to 'Mailer'
- MessageDataCollector::getName in vendor/
symfony/ mailer/ DataCollector/ MessageDataCollector.php - Returns the name of the collector.
File
-
vendor/
symfony/ mailer/ Mailer.php, line 26
Namespace
Symfony\Component\MailerView source
final class Mailer implements MailerInterface {
public function __construct(TransportInterface $transport, ?MessageBusInterface $bus = null, ?EventDispatcherInterface $dispatcher = null) {
}
public function send(RawMessage $message, ?Envelope $envelope = null) : void {
if (null === $this->bus) {
$this->transport
->send($message, $envelope);
return;
}
$stamps = [];
if (null !== $this->dispatcher) {
// The dispatched event here has `queued` set to `true`; the goal is NOT to render the message, but to let
// listeners do something before a message is sent to the queue.
// We are using a cloned message as we still want to dispatch the **original** message, not the one modified by listeners.
// That's because the listeners will run again when the email is sent via Messenger by the transport (see `AbstractTransport`).
// Listeners should act depending on the `$queued` argument of the `MessageEvent` instance.
$clonedMessage = clone $message;
$clonedEnvelope = null !== $envelope ? clone $envelope : Envelope::create($clonedMessage);
$event = new MessageEvent($clonedMessage, $clonedEnvelope, (string) $this->transport, true);
$this->dispatcher
->dispatch($event);
$stamps = $event->getStamps();
if ($event->isRejected()) {
return;
}
}
try {
$this->bus
->dispatch(new SendEmailMessage($message, $envelope), $stamps);
} catch (HandlerFailedException $e) {
foreach ($e->getWrappedExceptions() as $nested) {
if ($nested instanceof TransportExceptionInterface) {
throw $nested;
}
}
throw $e;
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
Mailer::send | public | function | Overrides MailerInterface::send | |
Mailer::__construct | public | function |