You are here

public function HTMLMailMime::get in HTML Mail 8

Same name and namespace in other branches
  1. 8.3 src/Utility/HtmlMailMime.php \Drupal\htmlmail\Utility\HtmlMailMime::get()

Builds and returns the full multipart message with all its parts.

Searches for inline file references and attaches local files, if possible.

Parameters

string $params: (optional) An associative array used to override the HTMLMailMime::_build_params values for building this message.

string $filename: (optional) The filename where the message data should be written. The default is to return the message data as a string.

bool $skip_head: (optional) TRUE if only the message body should be generated. Defaults to FALSE: return both headers and body together.

Return value

mixed

  • FALSE: If an error occurred.
  • NULL: If $filename is set and no error occurred.
  • string: The formatted message if $filename is not set and no error occurred.
1 call to HTMLMailMime::get()
HTMLMailMime::toEmail in src/Utility/HTMLMailMime.php
Return a (headers, body) pair for sending.

File

src/Utility/HTMLMailMime.php, line 412
Provides the MailMIME class for creating MIME-formatted email messages.

Class

HTMLMailMime
Class HTMLMailMime.

Namespace

Drupal\htmlmail\Utility

Code

public function &get($params = NULL, $filename = NULL, $skip_head = FALSE) {
  if (isset($this->_htmlbody)) {
    $this->_htmlbody = preg_replace_callback([
      '#(?<!\\S)(src|background|href)\\s*(=)\\s*(["\'])(?!cid:)([^?]*?)(?<!\\.css)(?<!\\.js)(\\?.*?)?(\\3)(?=[ >])#i',
      '#(?<!\\S)(url)\\s*(\\()\\s*(["\'])(?!cid:)([^?]*?)(?<!\\.css)(?<!\\.js)(\\?.*?)?(\\3)(?=[ )])#i',
    ], [
      &$this,
      'attachRegex',
    ], $this->_htmlbody);
  }
  $get_return = parent::get($params, $filename, $skip_head);
  return self::successful($get_return);
}