function SendmailTransport::doSend
Overrides AbstractTransport::doSend
File
-
vendor/
symfony/ mailer/ Transport/ SendmailTransport.php, line 90
Class
- SendmailTransport
- SendmailTransport for sending mail through a Sendmail/Postfix (etc..) binary.
Namespace
Symfony\Component\Mailer\TransportCode
protected function doSend(SentMessage $message) : void {
$this->getLogger()
->debug(\sprintf('Email transport "%s" starting', __CLASS__));
$command = $this->command;
if ($recipients = $message->getEnvelope()
->getRecipients()) {
$command = str_replace(' -t', '', $command);
}
if (!str_contains($command, ' -f')) {
$command .= ' -f' . escapeshellarg($message->getEnvelope()
->getSender()
->getEncodedAddress());
}
$chunks = AbstractStream::replace("\r\n", "\n", $message->toIterable());
if (!str_contains($command, ' -i') && !str_contains($command, ' -oi')) {
$chunks = AbstractStream::replace("\n.", "\n..", $chunks);
}
foreach ($recipients as $recipient) {
$command .= ' ' . escapeshellarg($recipient->getEncodedAddress());
}
$this->stream
->setCommand($command);
$this->stream
->initialize();
foreach ($chunks as $chunk) {
$this->stream
->write($chunk);
}
$this->stream
->flush();
$this->stream
->terminate();
$this->getLogger()
->debug(\sprintf('Email transport "%s" stopped', __CLASS__));
}