You are here

function swiftmailer_test_swiftmailer_alter in Swift Mailer 8

Same name and namespace in other branches
  1. 8.2 tests/modules/swiftmailer_test/swiftmailer_test.module \swiftmailer_test_swiftmailer_alter()

Alter messages before sending it with SwiftMailer.

See also

\Drupal\swiftmailer\Plugin\Mail\SwiftMailer::mail

File

tests/modules/swiftmailer_test/swiftmailer_test.module, line 10

Code

function swiftmailer_test_swiftmailer_alter(Swift_Mailer &$swiftMailer, Swift_Message &$swiftMessage, &$message) {
  if ($message['module'] === 'swiftmailer_test') {
    $swiftMailer
      ->registerPlugin(new SwiftMailerDrupalStateLogger());
  }
  if ($message['key'] == 'test_1') {
    $swiftMessage
      ->setBody('Replace text in swiftmailer_test_swiftmailer_alter');
  }
}