protected function processHeaders(array $payload, Swift_Mime_SimpleMessage $message): array
    {
        $headers = [];

        foreach ($message->getHeaders()->getAll() as $key => $value) {
            $fieldName       = $value->getFieldName();
            $excludedHeaders = ['Subject', 'Content-Type', 'MIME-Version', 'Date'];

            if (! \in_array($fieldName, $excludedHeaders, true)) {
                if ($value instanceof Swift_Mime_Headers_UnstructuredHeader) {
                    $headers[] = [
                        'Name'  => $fieldName,
                        'Value' => $value->getValue(),
                    ];
                } elseif ($value instanceof Swift_Mime_Headers_DateHeader ||
                    $value instanceof Swift_Mime_Headers_IdentificationHeader ||
                    $value instanceof Swift_Mime_Headers_ParameterizedHeader ||
                    $value instanceof Swift_Mime_Headers_PathHeader
                ) {
                    $headers[] = [
                        'Name'  => $fieldName,
                        'Value' => $value->getFieldBody(),
                    ];

                    if ($value->getFieldName() === 'Message-ID') {
                        $headers[] = [
                            'Name'  => 'X-PM-KeepID',
                            'Value' => 'true',
                        ];
                    }
                }
            }
        }

        $payload['Headers'] = $headers;

        return $payload;
    }