protected static function prepareHeaders(Swift_Mime_Message $message, $mailjetHeaders)
    {
        $messageHeaders = $message->getHeaders();

        $mailjetData = [];

        foreach (array_keys($mailjetHeaders) as $headerName) {
            /** @var \Swift_Mime_Headers_UnstructuredHeader $value */
            if (null !== $value = $messageHeaders->get($headerName)) {
                // Handle custom headers
                if($headerName == "X-MJ-Vars" && is_string($value->getValue())){
                    $mailjetData[$mailjetHeaders[$headerName]] = json_decode($value->getValue());
                } else {
                    $mailjetData[$mailjetHeaders[$headerName]] = $value->getValue();
                }
                // remove Mailjet specific headers
                $messageHeaders->removeAll($headerName);
            }
        }

        return $mailjetData;
    }
protected static function prepareHeaders(Swift_Mime_Message $message, $mailjetHeaders)
    {
        $messageHeaders = $message->getHeaders();

        $mailjetData = [];

        foreach (array_keys($mailjetHeaders) as $headerName) {
            /** @var \Swift_Mime_Headers_UnstructuredHeader $value */
            if (null !== $value = $messageHeaders->get($headerName)) {
                // Handle custom headers
                if($headerName == "X-MJ-Vars" && is_string($value->getValue())){
                    $mailjetData[$mailjetHeaders[$headerName]] = json_decode($value->getValue());
                } else {
                    $mailjetData[$mailjetHeaders[$headerName]] = $value->getValue();
                }
                // remove Mailjet specific headers
                $messageHeaders->removeAll($headerName);
            }
        }

        return $mailjetData;
    }
protected static function prepareHeaders ( Swift_Mime_Message $ message , $ mailjetHeaders ) { $ messageHeaders = $ message -> getHeaders ( ) ; $ mailjetData = [ ] ; foreach ( array_keys ( $ mailjetHeaders ) as $ headerName ) { /** @var \Swift_Mime_Headers_UnstructuredHeader $value */ if ( null !== $ value = $ messageHeaders -> get ( $ headerName ) ) { // Handle custom headers if ( $ headerName == "X-MJ-Vars" && is_string ( $ value -> getValue ( ) ) ) { $ mailjetData [ $ mailjetHeaders [ $ headerName ] ] = json_decode ( $ value -> getValue ( ) ) ; } else { $ mailjetData [ $ mailjetHeaders [ $ headerName ] ] = $ value -> getValue ( ) ; } // remove Mailjet specific headers $ messageHeaders -> removeAll ( $ headerName ) ; } } return $ mailjetData ; }
Extract Mailjet specific header
return an array of formatted data for Mailjet send API

@param Swift_Mime_Message $message
@param array              $mailjetHeaders

@return array
Extract Mailjet specific header return an array of formatted data for Mailjet send API