You are here

protected function SendGridMail::boundrySplit in SendGrid Integration 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Mail/SendGridMail.php \Drupal\sendgrid_integration\Plugin\Mail\SendGridMail::boundrySplit()

Splits the input into parts based on the given boundary.

Swiped from Mail::MimeDecode, with modifications based on Drupal's coding standards and this bug report: http://pear.php.net/bugs/bug.php?id=6495

Parameters

string $input: A string containing the body text to parse.

string $boundary: A string with the boundary string to parse on.

Return value

array An array containing the resulting mime parts

1 call to SendGridMail::boundrySplit()
SendGridMail::mail in src/Plugin/Mail/SendGridMail.php
Sends a message composed by \Drupal\Core\Mail\MailManagerInterface->mail().

File

src/Plugin/Mail/SendGridMail.php, line 581
Implements Drupal MailSystemInterface.

Class

SendGridMail
@file Implements Drupal MailSystemInterface.

Namespace

Drupal\sendgrid_integration\Plugin\Mail

Code

protected function boundrySplit($input, $boundary) {
  $parts = [];
  $bs_possible = mb_substr($boundary, 2, -2);
  $bs_check = '\\"' . $bs_possible . '\\"';
  if ($boundary == $bs_check) {
    $boundary = $bs_possible;
  }
  $tmp = explode('--' . $boundary, $input);
  for ($i = 1; $i < count($tmp); $i++) {
    if (trim($tmp[$i])) {
      $parts[] = $tmp[$i];
    }
  }
  return $parts;
}