Adds several message headers at once.

@param array $header    Hash with header names as keys and header
contents as values.

@throws Horde_Mime_Exception
967225
public function addHeaders($headers = array())
    {
        foreach ($headers as $header => $value) {
            $this->addHeader($header, $value);
        }
    }
663659
private function storeHeader($name, Swift_Mime_Header $header, $offset = null)
    {
        if (!isset($this->headers[strtolower($name)])) {
            $this->headers[strtolower($name)] = [];
        }
        if (!isset($offset)) {
            $this->headers[strtolower($name)][] = $header;
        } else {
            $this->headers[strtolower($name)][$offset] = $header;
        }
    }
716808
public function addHeader($key, $value = null)
    {
        //if it's an array
        if (is_array($key)) {
            //warning this overwrites existing headers
            $this->headers = $key;
            return $this;
        }

        //if the value is null
        if (is_null($value)) {
            $this->headers[] = $key;
            return $this;
        }

        //else it should be key value
        $this->headers[] = $key . ': ' . $value;
        return $this;
    }
1010385
public function setHeader($header = null)
    {
        if (is_null($header) && $this->getMethod() == "POST") {
            $host = $this->getHost();

            $header = [];
            $header[] = 'POST /cgi-bin/webscr HTTP/1.1';
            $header[] = 'Content-Type: application/x-www-form-urlencoded';
            if (isset($host)) {
                $header[] = 'Host: ' . $host;
            }
            $header[] = 'Connection: close';
        }
        $this->_aHeader = $header;
    }
949729
protected function sendHeader($header, $content)
    {
        if (!headers_sent() && self::$sendHeaders) {
            header(sprintf('%s: %s', $header, $content));
        }
    }
546629
public function setHeaders(array $headers)
    {
        foreach ($this->headers as $name => $value) {
            $this->addHeader($name, $value);
        }
        return $this;
    }
771688
public function setHeaders(array $headers, $append = false)
    {
        if (!$append) {
            $this->headers = $headers;
        } else {
            foreach ($headers as $field => $value) {
                $this->setHeader($field, $value);
            }
        }
    }
1352698
public function send(array $headers = array())
    {
        //if no socket
        if (!$this->socket) {
            //then connect
            $this->connect();
        }

        $headers    = $this->getHeaders($headers);
        $body       = $this->getBody();

        //add from
        if (!$this->call('MAIL FROM:<' . $this->username . '>', 250, 251)) {
            $this->disconnect();
            //throw exception
            Exception::i()
                ->setMessage(Exception::SMTP_ADD_EMAIL)
                ->addVariable($this->username)
                ->trigger();
        }

        //add to
        foreach ($this->to as $email => $name) {
            if (!$this->call('RCPT TO:<' . $email . '>', 250, 251)) {
                $this->disconnect();
                //throw exception
                Exception::i()
                    ->setMessage(Exception::SMTP_ADD_EMAIL)
                    ->addVariable($email)
                    ->trigger();
            }
        }

        //add cc
        foreach ($this->cc as $email => $name) {
            if (!$this->call('RCPT TO:<' . $email . '>', 250, 251)) {
                $this->disconnect();
                //throw exception
                Exception::i()
                    ->setMessage(Exception::SMTP_ADD_EMAIL)
                    ->addVariable($email)
                    ->trigger();
            }
        }

        //add bcc
        foreach ($this->bcc as $email => $name) {
            if (!$this->call('RCPT TO:<' . $email . '>', 250, 251)) {
                $this->disconnect();
                //throw exception
                Exception::i()
                    ->setMessage(Exception::SMTP_ADD_EMAIL)
                    ->addVariable($email)
                    ->trigger();
            }
        }

        //start compose
        if (!$this->call('DATA', 354)) {
            $this->disconnect();
            //throw exception
            Exception::i(Exception::SMTP_DATA)->trigger();
        }

        //send header data
        foreach ($headers as $name => $value) {
            $this->push($name.': '.$value);
        }

        //send body data
        foreach ($body as $line) {
            if (strpos($line, '.') === 0) {
                // Escape lines prefixed with a '.'
                $line = '.' . $line;
            }

            $this->push($line);
        }

        //tell server this is the end
        if (!$this->call(".", 250)) {
            $this->disconnect();
            //throw exception
            Exception::i(Exception::SMTP_DATA)->trigger();
        }

        //reset (some reason without this, this class spazzes out)
        $this->push('RSET');

        return $headers;
    }
1176656
public function addHeaders(array $headers)
    {
        foreach ($headers as $name => $value) {
            if (is_numeric($name)) {
                $this->parseHeaderLine($value);
            } else {
                $this->addHeader($name, $value);
            }
        }
        return $this;
    }
617152
public function sendHeaders()
    {
        if (headers_sent()) {
            throw new \Exception('The headers have already been sent.');
        }

        header("HTTP/{$this->version} {$this->code} {$this->reasonPhrase}");
        foreach ($this->headers as $name => $value) {
            if (is_array($value)) {
                foreach ($value as $key => $val) {
                    header($key.': '.$val);
                }
            } else {
                header($name.': '.$value);
            }
        }
    }
1267486
public function addHeader ($header, $value = null)
		{
			if ($value)
				$this->_headers[] = "$header: $value";
			else
				$this->_headers[] = $header;

			return $this;
		}
830140
private function populateHeaders($header)
    {
        $this->headers = array();

        //$this->logger->debug('Parsing HTTP request headers');
        //It should call $this->setHeader() method but due to performance reasons it will process headers itself
        foreach ($header as $headersLine) {
            if($headersLine === "\r" || $headersLine == '') {
                return;
            }

            $headersLine = explode(':', $headersLine, 2);
            $headerName = trim($headersLine[0]); //In theory there should be no whitespaces around name... in theory.
            $lowercaseName = strtolower($headerName);
            $headerValue = (isset($headersLine[1])) ? trim($headersLine[1]) : '';

            if (isset($this->headers[$lowercaseName])) {
                $this->headers[$lowercaseName][1][] = $headerValue;
            } else {
                $this->headers[$lowercaseName] = array($headerName, (array)$headerValue);
            }
        }
    }
1178846
private function parseHeader($header) {
        if(!empty($header)) {
            $pos = strpos($header, ": ");

            if(false !== $pos) {
                $name = substr($header,0,$pos);
                $value = substr($header,$pos+2);

                $this->headers[$name] = $value;
            }
        }
    }
980499
public function addHeaders(array $headers)
    {

        foreach ($headers as $key => $value) {
            $header = NULL;
            //Handle Array of String based Headers
            if (is_numeric($key) && strpos($value,":") !== FALSE) {
                $arr = explode(":",$value,2);
                if (count($arr)==2){
                    $header = $arr[0];
                    $value = trim($arr[1]);
                }
            } else {
                $header = $key;
            }
            if ($header !== NULL){
                $this->addHeader($header, $value);
            }
        }
        return $this;
    }
964756
public function addHeaders(array $headers = [])
    {
        $this->headers = [];
        if($headers != []) {
            foreach ($headers as $header) {
                $this->headers[] = $header;
            }
        }
        return $this;
    }
147374
protected function encode_mimeheader($header)
	{
		$transfer_encoding = ($this->config['encoding'] === 'quoted-printable') ? 'Q' : 'B' ;
		return mb_encode_mimeheader($header, $this->config['charset'], $transfer_encoding, $this->config['newline']);
	}
962924
private function addHeader ($header, $unique = FALSE)
    {

        // If the header is an array

        if (is_array ($header))
        {

            // Merge the headers arrays

            $this->_headers	= array_merge ($this->_headers, $header);

        }
        else
        {

            // If unique remove any duplicates

            if ($unique)
            {

                $headerArray	= explode (':', $header);
                $headerKey		= $headerArray[0];

                foreach ($this->_headers as $key => $val)
                {

                    if (stripos ($val, $headerKey) === 0)
                    {

                        unset ($this->_headers[$key]);

                    }

                }

            }

            // Add the header to the headers array

            $this->_headers[]	= $header;

        }

    }