protected function buildHeaders()
    {
        $headers = array();
        foreach ($this->headers as $key => $value) {
            if ($key == 'CC' || $key == 'BCC') {
                $value = implode(', ', $value);
            }
            array_push($headers, sprintf('%s: %s', $key, $value));
        }

        if (!empty($this->attachments)) {
            array_push(
                $headers,
                "Content-Type: multipart/mixed; boundary=\"{$this->boundaryMixed}\""
            );
        } elseif (!empty($this->plainMessage) && !empty($this->htmlMessage)) {
            array_push(
                $headers,
                "Content-Type: multipart/alternative; boundary=\"{$this->boundaryAlternative}\""
            );
        } elseif (!empty($this->htmlMessage)) {
            array_push(
                $headers,
                'Content-type: text/html; charset="iso-8859-1"'
            );
        }

        return implode(self::LINE_BREAK, $headers);
    }