public function PHPMailer::getMailMIME

5.x PHPMailer.php public PHPMailer::getMailMIME()

Get the message MIME type headers.

Return value

string

2 calls to PHPMailer::getMailMIME()
PHPMailer::createBody in inc/PHPMailer/src/PHPMailer.php
Assemble the message body. Returns an empty string on failure.
PHPMailer::createHeader in inc/PHPMailer/src/PHPMailer.php
Assemble message headers.

File

inc/PHPMailer/src/PHPMailer.php, line 2419

Class

PHPMailer
PHPMailer - PHP email creation and transport class.

Namespace

PHPMailer\PHPMailer

Code

public function getMailMIME() 
 {
  $result = '';
  $ismultipart = true;
  switch ($this->message_type) {
    case 'inline':
      $result .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_RELATED . ';');
      $result .= $this->textLine(' boundary="' . $this->boundary [1] . '"');
      break;
    case 'attach':
    case 'inline_attach':
    case 'alt_attach':
    case 'alt_inline_attach':
      $result .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_MIXED . ';');
      $result .= $this->textLine(' boundary="' . $this->boundary [1] . '"');
      break;
    case 'alt':
    case 'alt_inline':
      $result .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ';');
      $result .= $this->textLine(' boundary="' . $this->boundary [1] . '"');
      break;
    default:
      // Catches case 'plain': and case '':
      $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet);
      $ismultipart = false;
      break;
  }
  // RFC1341 part 5 says 7bit is assumed if not specified
  if (static::ENCODING_7BIT != $this->Encoding) {
    // RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE
    if ($ismultipart) {
      if (static::ENCODING_8BIT == $this->Encoding) {
        $result .= $this->headerLine('Content-Transfer-Encoding', static::ENCODING_8BIT);
      }
      // The only remaining alternatives are quoted-printable and base64, which are both 7bit compatible
    }
    else {
      $result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding);
    }
  }

  if ('mail' != $this->Mailer) {
    $result .= static::$LE;
  }

  return $result;
}