You are here

class BusinessRulesMail in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Mail/BusinessRulesMail.php \Drupal\business_rules\Plugin\Mail\BusinessRulesMail

Provides a 'Business Rules Mail' plugin to send emails.

Plugin annotation


@Mail(
  id = "business_rules_mail",
  label = @Translation("Business Rules Mailer"),
  description = @Translation("Business Rules Mailer Plugin.")
)

Hierarchy

Expanded class hierarchy of BusinessRulesMail

File

src/Plugin/Mail/BusinessRulesMail.php, line 18

Namespace

Drupal\business_rules\Plugin\Mail
View source
class BusinessRulesMail extends PhpMail implements MailInterface {

  /**
   * Formats a message composed by drupal_mail().
   *
   * @param array $message
   *   A message array holding all relevant details for the message.
   *
   * @return array
   *   The message as it should be sent.
   */
  public function format(array $message) {

    // Join the body array into one string.
    $message['body'] = implode("\n\n", $message['body']);
    if (!isset($message['headers']) || !isset($message['headers']['Content-Type']) || !stristr($message['headers']['Content-Type'], 'text/html')) {

      // Convert any HTML to plain-text.
      $message['body'] = MailFormatHelper::htmlToText($message['body']);

      // Wrap the mail body for sending.
      $message['body'] = MailFormatHelper::wrapMail($message['body']);
    }
    return $message;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BusinessRulesMail::format public function Formats a message composed by drupal_mail(). Overrides PhpMail::format
PhpMail::$configFactory protected property The configuration factory.
PhpMail::mail public function Sends an email message. Overrides MailInterface::mail 2
PhpMail::_isShellSafe protected static function Disallows potentially unsafe shell characters.
PhpMail::__construct public function PhpMail constructor.