private function sign(Message &$message)
    {
        // generate signature
        $signature = $this->generateSignature();

        // first remove the empty dkim header
        $message->getHeaders()->removeHeader('DKIM-Signature');

        // generate new header set starting with the dkim header
        $headerSet[] = new Dkim($this->getEmptyDkimHeader()->getFieldValue() . $signature);

        // then append existing headers
        $headers = $message->getHeaders();
        foreach($headers as $header) {
            $headerSet[] = $header;
        }

        // clear headers
        $message->getHeaders()->clearHeaders();

        // add the newly created header set with the dkim signature
        $message->getHeaders()->addHeaders($headerSet);
    }