function AbstractStream::write
File
-
vendor/
symfony/ mailer/ Transport/ Smtp/ Stream/ AbstractStream.php, line 37
Class
- AbstractStream
- A stream supporting remote sockets and local processes.
Namespace
Symfony\Component\Mailer\Transport\Smtp\StreamCode
public function write(string $bytes, bool $debug = true) : void {
if ($debug) {
$timestamp = (new \DateTimeImmutable())->format('Y-m-d\\TH:i:s.up');
foreach (explode("\n", trim($bytes)) as $line) {
$this->debug .= \sprintf("[%s] > %s\n", $timestamp, $line);
}
}
$bytesToWrite = \strlen($bytes);
$totalBytesWritten = 0;
while ($totalBytesWritten < $bytesToWrite) {
$bytesWritten = @fwrite($this->in, substr($bytes, $totalBytesWritten));
if (false === $bytesWritten || 0 === $bytesWritten) {
throw new TransportException('Unable to write bytes on the wire.');
}
$totalBytesWritten += $bytesWritten;
}
}