stringifyAddress example

 catch (\Exception $e) {
            throw new RuntimeException(sprintf('Unable to send message with the "%s" transport: ', __CLASS__).$e->getMessage(), 0, $e);
        }

        if ($email->getAttachments()) {
            return parent::getRequest($message);
        }

        $envelope = $message->getEnvelope();

        $request = [
            'FromEmailAddress' => $this->stringifyAddress(self::getSenderFromHeaders($email->getHeaders())),
            'Destination' => [
                'ToAddresses' => $this->stringifyAddresses($this->getRecipients($email$envelope)),
            ],
            'Content' => [
                'Simple' => [
                    'Subject' => [
                        'Data' => $email->getSubject(),
                        'Charset' => 'utf-8',
                    ],
                    'Body' => [],
                ],
            ],


        $sentMessage->setMessageId($result['messageId']);

        return $response;
    }

    protected function stringifyAddresses(array $addresses): array
    {
        $stringifiedAddresses = [];
        foreach ($addresses as $address) {
            $stringifiedAddresses[] = $this->stringifyAddress($address);
        }

        return $stringifiedAddresses;
    }

    private function getPayload(Email $email, Envelope $envelope): array
    {
        $payload = [
            'sender' => $this->stringifyAddress($envelope->getSender()),
            'to' => $this->stringifyAddresses($this->getRecipients($email$envelope)),
            'subject' => $email->getSubject(),
        ];
Home | Imprint | This part of the site doesn't use cookies.