Creates recipient headers.
@access public
@return string
5192
public function AddrAppend($type, $addr) {
    $addr_str = $type . ': ';
    $addresses = array();
    foreach ($addr as $a) {
      $addresses[] = $this->AddrFormat($a);
    }
    $addr_str .= implode(', ', $addresses);
    $addr_str .= $this->LE;

    return $addr_str;
  }
419775
public function getHttpHeaders()
    {
        if ($this->headers === null) {
            $this->headers = new SimpleHeaders();
            $this->headers->setContentType('text/csv', $this->options['charset']);
            //$this->headers->setContentDispositionType(SimpleHeaders::DIPOSITION_ATTACHEMENT);
        }

        return $this->headers;
    }
724094
public function generateHeaders()
    {
        // Workaround for encoded email addresses.
        // When encoded, email addresses (at least the name param) have more characters
        // By default, line length is set to 76 characters, after what a new line is created with $lineBreak.
        // This operation is done during encoding via iconv (see ezcMailTools::composeEmailAddress()).
        // Problem is that this operation is done a 2nd time in ezcMailPart::generateHeaders().
        // Following code ensures that there is no double $lineBreak introduced
        // by this process because it potentially breaks headers
        $lineBreak = ezcMailTools::lineBreak();
        $headers = str_replace( "$lineBreak$lineBreak", $lineBreak, parent::generateHeaders() );
        return $headers;
    }
177982
public function getMailHeadersAsString()
    {
        $headerString = "";

        foreach ($this->getMailHeaders() as $header => $value) {
            $headerString .= $header . ": " . $value . "\r\n";
        }

        return trim($headerString);
    }
413136
public function buildHeader() {
    $header['id'] = $this->t('Internal ID');
    $header['name'] = $this->t('Name');
    $header['mail'] = $this->t('Email');
    $header['region'] = $this->t('Branch (Region)');
    $header['membership_id'] = $this->t('Membership ID');
    $header['is_employee'] = $this->t('Employee');
    $header['checkins'] = $this->t('Checkins');
    $header['campaigns'] = $this->t('Campaigns');
    return $header + parent::buildHeader();
  }
616595
public function send()
    {
        //Check if a sender is available.
        if (empty(trim($this->sender))) {
            return false;
        }
        if ((is_array($this->receivers) === false) || (count($this->receivers) < 1)) {
            return false;
        }
        $receivers = implode(',', $this->receivers);
        if (!empty(trim($this->replyTo))) {
            $headers[] = 'Reply-To: '.$this->replyTo;
        } else {
            $headers[] = 'Reply-To: '.$this->sender;
        }
        if ((is_array($this->bcc) === true) && (count($this->bcc) > 0)) {
            $headers[] = 'Bcc: '.implode(',', $this->bcc);
        }
        if ((is_array($this->cc) === true) && (count($this->cc) > 0)) {
            $headers[] = 'Cc: '.implode(',', $this->cc);
        }
        //Generate boundaries for mail content areas.
        $boundaryMessage = md5(rand().'message');
        $boundaryContent = md5(rand().'content');
        //Set the header informations of the mail.
        $headers = [];
        $headers[] = 'MIME-Version: 1.0';
        $headers[] = 'X-Mailer: PHP/'.phpversion();
        $headers[] = 'Date: '.date('r', $_SERVER['REQUEST_TIME']);
        $headers[] = 'X-Originating-IP: '.$_SERVER['SERVER_ADDR'];
        $headers[] = 'Content-Type: multipart/related;boundary='.$boundaryMessage;
        $headers[] = 'Content-Transfer-Encoding: 8bit';
        $headers[] = 'From: '.$this->sender;
        $headers[] = 'Return-Path: '.$this->sender;
        //Start to generate the content of the mail.
        $msgContent = "\r\n".'--'.$boundaryMessage."\r\n";
        $msgContent .= 'Content-Type: multipart/alternative; boundary='.$boundaryContent."\r\n";
        if (!empty(trim($this->contentPlain))) {
            $msgContent .= "\r\n".'--'.$boundaryContent."\r\n";
            $msgContent .= 'Content-Type: text/plain; charset=ISO-8859-1'."\r\n";
            $msgContent .= "\r\n".$this->contentPlain."\r\n";
        }
        if (!empty(trim($this->contentHTML))) {
            $msgContent .= "\r\n".'--'.$boundaryContent."\r\n";
            $msgContent .= 'Content-Type: text/html; charset=ISO-8859-1'."\r\n";
            $msgContent .= "\r\n".$this->contentHTML."\r\n";
        }
        //Close the message area of the mail.
        $msgContent .= "\r\n".'--'.$boundaryContent.'--'."\r\n";
        foreach ($this->attachments as $attachment) {
            $attachmentContent = $this->prepareAttachment($attachment);
            if ($attachmentContent !== false) {
                $msgContent .= "\r\n".'--'.$boundaryMessage."\r\n";
                $msgContent .= $attachmentContent;
            }
        }
        //Close the area of the whole mail content.
        $msgContent .= "\r\n".'--'.$boundaryMessage.'--'."\r\n";
        if (!isset($this->smtp['status']) || $this->smtp['status'] === false) {
            $return = mail($receivers, $this->subject, $msgContent, implode("\r\n", $headers), $this->addparams);
        } else {
            $return = $this->sendSMTP($receivers, $this->sender, $msgContent);
        }

        return $return;
    }
1160541
final public function createSendableMessage(): string
    {
        $variableHeader = $this->createVariableHeader();
        $this->logger->debug('Created variable header', ['variableHeader' => base64_encode($variableHeader)]);
        $payload = $this->createPayload();
        $this->logger->debug('Created payload', ['payload' => base64_encode($payload)]);
        $fixedHeader = $this->createFixedHeader(strlen($variableHeader . $payload));
        $this->logger->debug('Created fixed header', ['fixedHeader' => base64_encode($fixedHeader)]);

        return $fixedHeader . $variableHeader . $payload;
    }
709977
public function generateHeader()
    {
        $format     = 'Rounds="%s", App="%s", Nonce="%s", Token="%s", Realm="%s", User="%s"';
        $expiresAt  = null;

        if ($this->getExpiresAt()) {
            $format = $format . ', ExpiresAt="%s"';
            $expiresAt  = $this->getExpiresAt()->format(\DateTime::ATOM);
        }

        return sprintf(
            $format,
            $this->getRounds(),
            $this->getApp(),
            $this->getNonce(),
            $this->getToken(),
            $this->getRealm(),
            $this->getUser(),
            $expiresAt
        );
    }
599670
public function sendHeaders()
     {
         $response = $this->getResponse();
         $headers = $response->getHeaders();
         $isAjax = $response->getRequest()->isAjax();

         if (isset($headers['Location']) && $response->isSuccess() && !$isAjax) {
             $response->setStatus(AnHttpResponse::SEE_OTHER);
         }

         return parent::sendHeaders();
     }
91022
public function sendHeaders()
	{
		// Early return if headers already have been send
		if (headers_sent()) {
			return $this;
		}

		foreach ($this->headers as $key => $value) {
			header(
				sprintf('%s: %s', $key, is_array($value) ? implode('; ', $value) : $value),
				true,
				$this->statusCode
			);
		}

		header(sprintf('%s %s %s',
			self::$protocolVersionMap[$this->protocolVersion],
			$this->statusCode,
			self::$statusCodeMap[$this->statusCode]
		));

		return $this;
	}
384484
protected static function buildAdditionalHeadersString(&$headers)
    {
        $headersAddStr = '';
        $eol = "\r\n";
        foreach ($headers as $k => $v) {
            if (in_array($k, array('To','Subject','Body','Attachments'))) {
                continue;
            }
            if (empty($v)) {
                continue;
            }
            if ($k == 'From' && isset($_SERVER['WINDIR'])) {
                $fromAddress = preg_match('/<(.*?)>/', $v, $matches)
                    ? $matches[1]
                    : $v;
                // $this->debug->log('setting sendmail_from to '.$fromAddress);
                ini_set('sendmail_from', $fromAddress);
            }
            $headersAddStr .= $k.': '.$v.$eol;
        }
        $headersAddStr = substr($headersAddStr, 0, -strlen($eol));  // remove final $eol;
        return $headersAddStr;
    }
215078
private function sendHeaders()
    {
        if (!array_key_exists('Content-Type', $this->headers)) {
            $this->headers['Content-Type'] = 'text/html; charset=UTF-8';
        }

        $this->headers['Content-Length'] = strlen($this->body);

        header(
            sprintf(
                'HTTP/%s %s %s',
                $this->request->server('SERVER_PROTOCOL'),
                $this->numericStatusCode,
                $this->textualStatusCode ?: $this->statusCode->getText($this->numericStatusCode)
            ),
            true,
            $this->numericStatusCode
        );

        foreach ($this->headers as $key => $value) {
            header(sprintf('%s: %s', $key, $value));
        }
    }
995653
private function buildHeaderResponse()
    {
        foreach (explode(
            "\n",
            substr($this->output, 0, $this->info['header_size'])
        ) as $val) {
            $val = trim($val);
            if (! empty($val)) {
                $this->headerResponse[] = $val;
            }
        }
        $this->output = substr($this->output, $this->info['header_size']);
    }
1021996
public function compileHeaders()
    {
        if (count($this->attachement) > 0) {
            $this->headers[] = "Content-type: multipart/mixed; boundary=\"{$this->boundary}\"" . self::END;

            foreach ($this->attachement as $file) {
                $filename = basename($file);
                $this->headers[] = "--" . $this->boundary;
                $this->headers[] = "Content-Type: application/octet-stream; name=\"{$filename}\"";
                $this->headers[] = "Content-Transfer-Encoding: base64";
                $this->headers[] = "Content-Disposition: attachment" . self::END;
                $this->headers[] = chunk_split(base64_encode(file_get_contents($file)));
            }

            $this->headers[] = "--" . $this->boundary;
        }

        return implode(self::END, $this->headers).self::END;
    }
180667
private function sendUsingPHP ()
    {

        // Construct Headers

        $headers	= $this->constructHeaders ();

        // Get template resource

        $tpl	= \Sonic\Sonic::getResource ('tpl');

        // Set smarty template status

        $smarty	= $tpl instanceof \Smarty;

        // If we have a smarty template object

        if ($smarty)
        {

            // Get caching status

            $smartyPrevCache	= $tpl->caching;

            // Disable caching

            $tpl->setCaching (FALSE);

        }

        // For each recipient

        foreach ($this->_recipients as $recipient)
        {

            // Send email

            try
            {

                // Check to make sure the recipients email address is valid

                Parser::_validateEmail ($recipient['email']);

                // Set recipient

                if (isset($recipient['name'])) {
                    $recipientTo = $recipient['name'] . '<' . $recipient['email'] . '>';
                } else {
                    $recipientTo = $recipient['email'];
                }

                // Add recipient header to original headers

                $emailHeaders	= $headers . 'To: ' . $recipientTo . $this->_nl;

                // If we're using smarty

                if ($smarty)
                {

                    // Clear variables

                    $tpl->clearAllAssign ();

                    // Assign variables

                    $tpl->assign ('recipient', $recipient);

                    // Fetch

                    $emailMessage	= $tpl->fetch ('string:' . $this->_message);

                }

                // Else we're not using smarty

                else
                {

                    // Just leave the message as it is

                    $emailMessage	= $this->_message;

                }

                // Send Message

                if (!mail ($recipientTo, $this->_subject, $emailMessage, $emailHeaders))
                {

                    // Add error and return FALSE

                    new \Sonic\Message ('error', 'Cannot send message to: ' . $recipient['email']);

                    // return FALSE

                    return FALSE;

                }

                if (is_callable($this->_callbackMethod))
                {
                    call_user_func ($this->_callbackMethod, $this->_subject, $recipientTo, $this->_fromAddress, $emailMessage);
                }


                // If we're logging the email

                if ($this->logFlag)
                {

                    // Log

                    $this->Log ($recipient['email'], $emailHeaders, $emailMessage, 'phpmail');

                }

            }

                // Else the email address is not valid

            catch (Parser\Exception $e)
            {

                // Add error

                new \Sonic\Message ('error', 'Invalid recipient email address: ' . $recipient['email']);

                // Skip to next recipient

                continue;

            }

        }

        // If we're using smarty

        if ($smarty)
        {

            // Set caching status

            $tpl->caching	= $smartyPrevCache;

        }

        // Return TRUE

        return TRUE;

    }
1189939
private function createHeaders($headers)
    {
        if (is_string($headers)) {
            return $this->createHeaders(explode("\r\n", $headers));
        }

        $fixedHeaders = array();

        foreach ($headers as $key => $header) {
            if (is_int($key)) {
                if (($pos = strpos($header, ':')) === false) {
                    continue;
                }

                $fixedHeaders[substr($header, 0, $pos)] = substr($header, $pos + 1);
            } else {
                $fixedHeaders[$key] = $this->createHeader($header);
            }
        }

        return $fixedHeaders;
    }
278898
protected function getHeadersAsText()
    {
        $headers = '';

        foreach ($this->headers as $header) {
            foreach ($header[1] as $headerValue) {
                $headers .= $header[0] . ': ' . $headerValue . "\r\n";
            }
        }

        return $headers;
    }