Generate header content

@since   1.0
@return  string Return header content of mail
505399
public function getHeaderContent()
    {
        $headerContent = '';
        $sender = $this->getSender();
        if (!empty($sender)) {
            $headerContent .= 'From: ' . $sender . PHP_EOL;
        }
        $reply = $this->getReply();
        if (!empty($reply)) {
            $headerContent .= 'Reply-to: ' . $reply . PHP_EOL;
        }
        $recipientCc = $this->getRecipientCc();
        if (!empty($recipientCc)) {
            $headerContent .= 'Cc: ' . $recipientCc . PHP_EOL;
        }
        $recipientBcc = $this->getRecipientBcc();
        if (!empty($recipientBcc)) {
            $headerContent .= 'Bcc: ' . $recipientBcc . PHP_EOL;
        }
        if (!empty($this->mailer)) {
            $headerContent .= 'X-Mailer: ' . $this->mailer . PHP_EOL;
        }
        $headerContent .= 'MIME-Version: 1.0' . PHP_EOL;
        if (!empty($this->attachmentList)) {
            $contentType = 'multipart/mixed';
        } else {
            $contentType = 'multipart/alternative';
        }
        $headerContent .= 'Content-Type: ' . $contentType . '; boundary="' . $this->boundary . '"';
        $headerContent .= PHP_EOL . PHP_EOL;
        return $headerContent;
    }
324024
public function generateHeaders()
    {
        // set our headers first.
        if ( $this->from !== null )
        {
            $this->setHeader( "From", ezcMailTools::composeEmailAddress( $this->from ) );
        }

        if ( $this->to !== null )
        {
            $this->setHeader( "To", ezcMailTools::composeEmailAddresses( $this->to ) );
        }
        if ( count( $this->cc ) )
        {
            $this->setHeader( "Cc", ezcMailTools::composeEmailAddresses( $this->cc ) );
        }
        if ( count( $this->bcc ) && $this->options->stripBccHeader === false )
        {
            $this->setHeader( "Bcc", ezcMailTools::composeEmailAddresses( $this->bcc ) );
        }

        $this->setHeader( 'Subject', $this->subject, $this->subjectCharset );

        $this->setHeader( 'MIME-Version', '1.0' );
        $this->setHeader( 'User-Agent', 'eZ Components' );
        $this->setHeader( 'Date', date( 'r' ) );
        $idhost = $this->from != null && $this->from->email != '' ? $this->from->email : 'localhost';
        if ( is_null( $this->messageId ) )
        {
            $this->setHeader( 'Message-Id', '<' . ezcMailTools::generateMessageId( $idhost ) . '>' );
        }
        else
        {
            $this->setHeader( 'Message-Id', $this->messageID );
        }

        // if we have a body part, include the headers of the body
        if ( is_subclass_of( $this->body, "ezcMailPart" ) )
        {
            return parent::generateHeaders() . $this->body->generateHeaders();
        }
        return parent::generateHeaders();
    }
425267
private function header()
    {
        $fields = collect($this->entity->fields)->unique('type')->all();
        $codeArray = [];

        foreach ($fields as $name => $options) {
            $type = ucwords($options['type']);
            $className = 'Jaimeeee\\Panel\\Fields\\'.$type.'\\'.$type.'Field';

            if (method_exists($className, 'header')) {
                $codeArray[] = '  '.$className::header();
            }
        }

        return implode(chr(10), $codeArray);
    }
764391
public function getHeaders(): Headers
    {
        if (null === $this->headers) {
            $this->headers = new Headers(\imap_rfc822_parse_headers($this->getRawHeaders()));
        }

        return $this->headers;
    }
1183322
protected function sendViaMail()
    {
        $headers = '';

        if ($this->isHtml) {
            $headers = 'Content-Type: text/html' . PHP_EOL;
        }

        $headers .= 'From: ' . $this->getFrom() . PHP_EOL;

        $emailTo = array();
        foreach ($this->emailTo as $email => $name) {
            $thisTo = $email;

            if (!is_null($name)) {
                $thisTo = '"' . $name . '" <' . $thisTo . '>';
            }

            $emailTo[] = $thisTo;
        }

        $emailTo = implode(', ', $emailTo);

        return mail($emailTo, $this->subject, $this->body, $headers);
    }
263657
public function getSentMIMEMessage()
    {
        return rtrim($this->MIMEHeader . $this->mailHeader, "\n\r") . self::CRLF . self::CRLF . $this->MIMEBody;
    }
714844
public function getHeaderContent()
    {
        if (!$this->headerFileHandle) {
            return null;
        }

        fseek($this->headerFileHandle, 0);

        $lines = array();
        while ($line = trim(fgets($this->headerFileHandle), "\n\r")) {
            $lines[] = $line;
        }

        return $lines;
    }
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
        );
    }
291431
public function toHeading()
    {
        $results = '';

        foreach ($this->getParser()->toArray() as $name => $types) {
            if (in_array($name, $this->ignores)) {
                continue;
            }

            $results .= "\t\t\t".'<th>'.ucwords($name).'</th>'.PHP_EOL;
        }

        return $results;
    }
274213
public function getHeaders()
    {
        if (isset($this->parts[1])) {
            $headers = $this->getPart('headers', $this->parts[1]);
            foreach ($headers as $name => &$value) {
                if (is_array($value)) {
                    foreach ($value as &$v) {
                        $v = $this->decodeSingleHeader($v);
                    }
                } else {
                    $value = $this->decodeSingleHeader($value);
                }
            }

            return $headers;
        } else {
            throw new Exception(
                'setPath() or setText() or setStream() must be called before retrieving email headers.'
            );
        }
    }
1197069
public function getMailContent()
    {
        if (!empty($this->owner->SuccessMessageMail)) {
            return $this->owner->dbObject('SuccessMessageMail');
        } else {
            return SiteConfig::current_site_config()->dbObject('SuccessMessageMail');
        }
    }
891471
public function getEmailBodyContent()
    {
        if ($this->SendPlain) {
            return DBField::create_field('HTMLText', $this->EmailBody)->Plain();
        }
        return DBField::create_field('HTMLText', $this->EmailBodyHtml);
    }
200758
public function encode()
    {
        return $this->header->encode() . $this->getContent() . \str_repeat("\0", $this->header->getPaddingLength());
    }
910571
public function getHeadersAsString()
    {
        $headerString = '';
        foreach ($this->getHeaders() as $name => $header) {
            // build up a header string
            $headerString .= $name . ': ' . $header . PHP_EOL;
        }

        return $headerString;
    }
820513
public function createHeader()
    {
        $result = '';

        // Set the boundaries
        $uniq_id = md5(uniqid(time()));
        $this->boundary[1] = 'b1_' . $uniq_id;
        $this->boundary[2] = 'b2_' . $uniq_id;
        $this->boundary[3] = 'b3_' . $uniq_id;

        if ($this->MessageDate == '') {
            $this->MessageDate = self::rfcDate();
        }
        $result .= $this->headerLine('Date', $this->MessageDate);


        // To be created automatically by mail()
        if ($this->SingleTo === true) {
            if ($this->Mailer != 'mail') {
                foreach ($this->to as $toaddr) {
                    $this->SingleToArray[] = $this->addrFormat($toaddr);
                }
            }
        } else {
            if (count($this->to) > 0) {
                if ($this->Mailer != 'mail') {
                    $result .= $this->addrAppend('To', $this->to);
                }
            } elseif (count($this->cc) == 0) {
                $result .= $this->headerLine('To', 'undisclosed-recipients:;');
            }
        }

        $result .= $this->addrAppend('From', array(array(trim($this->From), $this->FromName)));

        // sendmail and mail() extract Cc from the header before sending
        if (count($this->cc) > 0) {
            $result .= $this->addrAppend('Cc', $this->cc);
        }

        // sendmail and mail() extract Bcc from the header before sending
        if ((
                $this->Mailer == 'sendmail' or $this->Mailer == 'qmail' or $this->Mailer == 'mail'
            )
            and count($this->bcc) > 0
        ) {
            $result .= $this->addrAppend('Bcc', $this->bcc);
        }

        if (count($this->ReplyTo) > 0) {
            $result .= $this->addrAppend('Reply-To', $this->ReplyTo);
        }

        // mail() sets the subject itself
        if ($this->Mailer != 'mail') {
            $result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject)));
        }

        if ($this->MessageID != '') {
            $this->lastMessageID = $this->MessageID;
        } else {
            $this->lastMessageID = sprintf('<%s@%s>', $uniq_id, $this->ServerHostname());
        }
        $result .= $this->HeaderLine('Message-ID', $this->lastMessageID);
        $result .= $this->headerLine('X-Priority', $this->Priority);
        if ($this->XMailer == '') {
            $result .= $this->headerLine(
                'X-Mailer',
                'PHPMailer ' . $this->Version . ' (https://github.com/PHPMailer/PHPMailer/)'
            );
        } else {
            $myXmailer = trim($this->XMailer);
            if ($myXmailer) {
                $result .= $this->headerLine('X-Mailer', $myXmailer);
            }
        }

        if ($this->ConfirmReadingTo != '') {
            $result .= $this->headerLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
        }

        // Add custom headers
        for ($index = 0; $index < count($this->CustomHeader); $index++) {
            $result .= $this->headerLine(
                trim($this->CustomHeader[$index][0]),
                $this->encodeHeader(trim($this->CustomHeader[$index][1]))
            );
        }
        if (!$this->sign_key_file) {
            $result .= $this->headerLine('MIME-Version', '1.0');
            $result .= $this->getMailMIME();
        }

        return $result;
    }
260108
private function getHeaders()
    {
        $result = [];
        foreach ($this->headers as $name => $value) {
            $result[] = sprintf("%s: %s", $name, $value);
        }

        return $result;
    }
89418
public function header()
    {
        // If we have tab content
        if (isset($this->content_html{0})) {
            // Tab sub-headers html
            $sub_headers = '';

            // Iterate tab group tabs only if there is atleast two sub headers
            if (sizeof($this->tabs) > 2) {
                foreach ($this->tabs as $tab) {
                    // Don't render this tab as sub header
                    if ($tab == $this) continue;

                    // Render tab header as sub-header
                    $sub_headers .= m()->view($this->header_view)->tab($tab)->output();
                }
            }

            // Render just last tab
            $this->header_html .= m()
                ->view($this->header_view)
                ->sub_headers($sub_headers)
                ->class(isset($sub_headers{0}) ? 'sub-tabs-list' : '')
                ->tab($this)// Pass this tab object as main
                ->tab_id(end($this->tabs)->id)// Pass last tabs object id as identifier
                ->output();
        }

        return $this->header_html;
    }