/*
Builds the email string.

@return string
544683
protected function buildEmailString()
    {
        $email = $this->prefix.$this->email;

        if (isset($this->subject) || isset($this->body)) {
            $data = [
                'subject' => $this->subject,
                'body'    => $this->body,
            ];
            $email .= '?'.http_build_query($data);
        }

        return $email;
    }
975525
public function Build ()
    {

        // Create Boundaries

        $boundary		= '=====' . md5 (uniqid (time ()));

        // Reset headers

        $this->_headers	= array ();

        // Add MIME Headers

        $this->addHeader ('MIME-version: 1.0');
        $this->addHeader ('Content-Type: Multipart/alternative;' . $this->_nl . chr (9) . 'boundary="' . $boundary . '"');

        // Start Message

        $this->_message	= NULL;

        // If there is a template file

        if ($this->_tpl)
        {

            // Load it and add to html

            $this->addHTML (@file_get_contents ($this->_tpl));

        }

        // If HTML data

        if ($this->_htmlSet || $this->_plain)
        {

            // Construct the HTML and add it to the message

            $this->_message	.= $this->constructHTML ($boundary);

        }

        // If Body

        if ($this->_bodySet)
        {

            // Construct the body

            if (!$this->constructBody ())
            {

                // Add error and return FALSE

                new \Sonic\Message ('error', 'Cannot add message body!');
                return FALSE;

            }

        }

        // If Attachments

        if ($this->_attachmentsSet)
        {

            // Add them to the message

            foreach ($this->_attachments as $attachment)
            {
                $this->_message	.= $this->constructAttachment ($attachment, $boundary);
            }

        }

        // Finish Message

        $this->_message	.= '--' . $boundary . '--' . $this->_nl;

        // Return TRUE

        return TRUE;

    }
1099676
private function formatNotify() {

		$notify = null;

		if(true === isset($this -> headers['notify'])) {

			$notify = $this -> emailsToString($this -> headers['notify']);

			if(null === $notify) {

				if(true === isset($this -> headers['from'])) {
					$notify = $this -> emailsToString($this -> headers['from']);
				}
				else {
					$notify = ini_get('sendmail_from');
				}
			}
		}
		
		return $notify;
	}
589375
public function CreateHeader() {
    $result = '';

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

    $result .= $this->HeaderLine('Date', self::RFCDate());
    if($this->Sender == '') {
      $result .= $this->HeaderLine('Return-Path', trim($this->From));
    } else {
      $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
    }

    // To be created automatically by mail()
    if($this->Mailer != 'mail') {
      if(count($this->to) > 0) {
        $result .= $this->AddrAppend('To', $this->to);
      } elseif (count($this->cc) == 0) {
        $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
      }
    }

    $from = array();
    $from[0][0] = trim($this->From);
    $from[0][1] = $this->FromName;
    $result .= $this->AddrAppend('From', $from);

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

    // sendmail and mail() extract Bcc from the header before sending
    if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (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 != '') {
      $result .= $this->HeaderLine('Message-ID',$this->MessageID);
    } else {
      $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
    }
    $result .= $this->HeaderLine('X-Priority', $this->Priority);
    $result .= $this->HeaderLine('X-Mailer', 'PHPMailer ' . self::VERSION . ' (phpmailer.codeworxtech.com)');

    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;
  }
1161432
private function build() {

        $this -> fill();

        $html = '<textarea';
    	
    	foreach($this -> attributes as $attribute => $value) {

            if('value' !== $attribute) {
                $html .= ' ' . $attribute . '="'. Escape :: attr($value) .'"';
            }
    	}

    	$html .= '>';

        if(true === isset($this -> attributes['value'])) {
            $html .= Escape :: attr($this -> attributes['value']);
        }

        $html .= '</textarea>';

        return $html;
    }
1141853
public function build()
    {
        return $this->from($this->email, $this->title)
            ->subject('Subject: '.$this->messages['subject'])
            ->view('extras::messages.email');
    }
608454
private function buildMsg() {

		if(isset($this->boundary)) {
			$this->msg = '--' . $this->boundary . self::CRLF;
			$this->msg .= 'Content-type: text/' . ($this->htmlMail ? 'html' : 'plain') . '; charset=' .$this->encoding . self::CRLF;
			$this->msg .= 'Content-Transfer-Encoding: 8bit' . self::CRLF . self::CRLF;
		}
		else {
			$this->msg = '';
		}

		$this->msg .= $this->mailText . self::CRLF;
		
		// add signature

		if(!empty($this->sig) && !$this->htmlMail) {
			$this->msg .= self::CRLF . self::CRLF . '-- ' . self::CRLF . $this->sig;
		}
			
		if(!count($this->attachments)) {
			$this->msg .= self::CRLF;
		}
		else {

			foreach($this->attachments as $f) {

			    // attached data always has a filename set

				$filename = empty($f['filename']) ? basename($f['path']) : $f['filename'];
	
				$this->msg .= self::CRLF . '--' . $this->boundary . self::CRLF;
				$this->msg .= sprintf('Content-Type: application/octet-stream; name="%s"', $filename) . self::CRLF;
				$this->msg .= sprintf('Content-Disposition: attachment; filename="%s"', $filename) . self::CRLF;
				$this->msg .= 'Content-Transfer-Encoding: base64' . self::CRLF . self::CRLF;

				if(isset($f['data'])) {
                    $this->msg .= rtrim(chunk_split(base64_encode($f['data']), 72, self::CRLF));
                }
				else {
                    $this->msg .= rtrim(chunk_split(base64_encode(file_get_contents($f['path'])), 72, self::CRLF));
                }
	
			}
			
			$this->msg .= self::CRLF . '--'. $this->boundary . '--' . self::CRLF;

		}
	}
887165
public function buildCode()
    {
        $res = '';
        foreach ($this->styles as $href => $val) {
            $res .= '<link href="' . $href . '" rel="stylesheet" type="text/css" />' . "\r\n";
        }

        return $res;
    }
154326
public function send()
    {
        $appEncoding = Configuration::read('application.encoding');
        $encoding = new Encoding();
        $subject = $this->addEncodeTag($this->subject);
        $headerContent = $this->getHeaderContent();
        $mailContent = $this->getEmailContent();
        if ($appEncoding != $this->charset) {
            $subject = $encoding->convert($subject, $appEncoding, $this->charset);
            $headerContent = $encoding->convert($headerContent, $appEncoding, $this->charset);
            $mailContent = $encoding->convert($mailContent, $appEncoding, $this->charset);
        }
        return mail($this->getRecipientTo(), $this->subject, $mailContent, $headerContent);
    }
888555
public function toString()
	{
		$attributes = $this->buildAttributes();

		$select = array();
		$select[] = '<select '.$attributes.'>';

		$firstValue = $this->firstValue;
		
		$value = isset($this->override) ? $this->override : (isset($this->attributes['value']) ? $this->attributes['value'] : '');

		if($firstValue)
		{
			$selected = $value == $firstValue['value'] ? 'selected' : '';
			$select[] = '<option '.$selected.' value="'.$firstValue['value'].'">'.$firstValue['label'].'</option>';
		}

		foreach($this->options as $val => $label)
		{
			if(is_array($label))
			{
				$select[] = '<optgroup label="'.$val.'">';
				foreach($label as $v => $l)
				{
					$selected = $v === $value ? 'selected' : '';
					$select[] = '<option '.$selected.' value="'.$v.'">'.$l.'</option>';
				}
				$select[] = '</optgroup>';
			}
			else
			{
				$selected = $val === $value ? 'selected' : '';
				$select[] = '<option '.$selected.' value="'.$val.'">'.$label.'</option>';
			}
		}

		$select[] = '</select>';

		return implode('', $select);
	}
1209045
function build(): string
    {
        if ($this->host !== null && $this->preferredFormat === static::ABSOLUTE) {
            return $this->buildAbsolute();
        } else {
            return $this->buildRelative();
        }
    }
437447
public function build()
    {
        $headers = array();
        foreach (get_object_vars($this) as $header => $value) {
            $headers[] = $header . ": " . (string)$value;
        }
        return $headers;
    }
881935
public function toString()
    {
        $result = "";
        if ($this->scheme) {
            $result .= $this->scheme.'://';
        }
        if ($this->user) {
            $result .= $this->user;
            if ($this->pass) {
                $result .= $this->user;
            }
            $result .= '@';
        }
        if ($this->host) {
            $result .= $this->host;
        }
        if ($this->port) {
            $result .= ':'.$this->port;
        }
        if ($this->pathSegments) {
            $result .= '/'.implode('/', $this->pathSegments);
        }
        if ($this->parameters) {
            $result .= '?'.http_build_query($this->parameters);
        }
        if ($this->fragment) {
            $result .= '#'.$this->fragment;
        }
        return $result;
    }
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();
  }
906506
public function build(): string
    {
        if (count($this->parameters) === 0) {
            return '';
        }

        $queryString = '';
        foreach ($this->parameters as $name => $value) {
            $queryString .= $this->buildQuery($name, $value);
        }

        return substr($queryString, 1);
    }
959452
public function buildMessage()
    {
        if (isset($this->message)) {
            return $this->message;
        }

        $this->message = [
            BuildUtil::removeNullElements([
                'type' => MessageType::FLEX,
                'altText' => $this->altText,
                'contents' => $this->containerBuilder->build(),
                'quickReply' => BuildUtil::build($this->quickReply, 'buildQuickReply'),
            ])
        ];

        return $this->message;
    }
1217230
public function buildSet()
	{
		$updates = [];

		foreach ($this->set as $field => $value)
		{
			if (is_object($value))
			{
				$updates[] = $this->connection->quoteName($field) . ' = ' . $value->build($this);
			}
			else
			{
				$updates[] = $this->connection->quoteName($field) . ' = ?';
				$this->bind(is_string($value) ? trim($value) : $value);
			}
		}

		return 'SET ' . implode(',', $updates);
	}