appendDebug example


                $this->stream->flush();
            } catch (TransportExceptionInterface $e) {
                throw $e;
            } catch (\Exception $e) {
                $this->stream->terminate();
                $this->started = false;
                $this->getLogger()->debug(sprintf('Email transport "%s" stopped', __CLASS__));
                throw $e;
            }
            $this->mtaResult = $this->executeCommand("\r\n.\r\n", [250]);
            $message->appendDebug($this->stream->getDebug());
            $this->lastMessageTime = microtime(true);
        } catch (TransportExceptionInterface $e) {
            $e->appendDebug($this->stream->getDebug());
            $this->lastMessageTime = 0;
            throw $e;
        }
    }

    /** * @internal since version 6.1, to be made private in 7.0 * * @final since version 6.1, to be made private in 7.0 */
sleep(5);
        $t->send(new RawMessage(''));
        $this->assertTransports($t, 0, []);
        $t->send(new RawMessage(''));
        $this->assertTransports($t, 1, []);
    }

    public function testFailureDebugInformation()
    {
        $t1 = $this->createMock(TransportInterface::class);
        $e1 = new TransportException();
        $e1->appendDebug('Debug message 1');
        $t1->expects($this->once())->method('send')->will($this->throwException($e1));
        $t1->expects($this->once())->method('__toString')->willReturn('t1');

        $t2 = $this->createMock(TransportInterface::class);
        $e2 = new TransportException();
        $e2->appendDebug('Debug message 2');
        $t2->expects($this->once())->method('send')->will($this->throwException($e2));
        $t2->expects($this->once())->method('__toString')->willReturn('t2');

        $t = new RoundRobinTransport([$t1$t2]);

        
return sprintf('ses+https://%s@%s', $configuration->get('accessKeyId')$host);
    }

    protected function doSend(SentMessage $message): void
    {
        $result = $this->sesClient->sendEmail($this->getRequest($message));
        $response = $result->info()['response'];

        try {
            $message->setMessageId($result->getMessageId());
            $message->appendDebug($response->getInfo('debug') ?? '');
        } catch (HttpException $e) {
            $exception = new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $e->getAwsMessage() ?: $e->getMessage()$e->getAwsCode() ?: $e->getCode())$e->getResponse()$e->getCode()$e);
            $exception->appendDebug($e->getResponse()->getInfo('debug') ?? '');

            throw $exception;
        }
    }

    protected function getRequest(SentMessage $message): SendEmailRequest
    {
        $request = [
            


    public function send(RawMessage $message, Envelope $envelope = null): ?SentMessage
    {
        $exception = null;

        while ($transport = $this->getNextTransport()) {
            try {
                return $transport->send($message$envelope);
            } catch (TransportExceptionInterface $e) {
                $exception ??= new TransportException('All transports failed.');
                $exception->appendDebug(sprintf("Transport \"%s\": %s\n", $transport$e->getDebug()));
                $this->deadTransports[$transport] = microtime(true);
            }
        }

        throw $exception ?? new TransportException('No transports found.');
    }

    public function __toString(): string
    {
        return $this->getNameSymbol().'('.implode(' ', array_map('strval', $this->transports)).')';
    }

    
$this->port = $port;

        return $this;
    }

    abstract protected function doSendHttp(SentMessage $message): ResponseInterface;

    protected function doSend(SentMessage $message): void
    {
        try {
            $response = $this->doSendHttp($message);
            $message->appendDebug($response->getInfo('debug') ?? '');
        } catch (HttpTransportException $e) {
            $e->appendDebug($e->getResponse()->getInfo('debug') ?? '');

            throw $e;
        }
    }
}
Home | Imprint | This part of the site doesn't use cookies.