You are here

protected function SendGridMailSystem::_boundary_split in SendGrid Integration 7

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

input: A string containing the body text to parse.

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

Return value

array An array containing the resulting mime parts

1 call to SendGridMailSystem::_boundary_split()
SendGridMailSystem::mail in inc/sendgrid.mail.inc
Implement mail method to send mail via Sendgrid.

File

inc/sendgrid.mail.inc, line 556
Implements Drupal MailSystemInterface.

Class

SendGridMailSystem
@file Implements Drupal MailSystemInterface.

Code

protected function _boundary_split($input, $boundary) {
  $parts = [];
  $bs_possible = drupal_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;
}