You are here

function hook_swiftmailer_alter in Swift Mailer 8.2

Same name and namespace in other branches
  1. 8 swiftmailer.api.php \hook_swiftmailer_alter()

Alter messages before sending it with SwiftMailer.

See also

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

1 function implements hook_swiftmailer_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

swiftmailer_test_swiftmailer_alter in tests/modules/swiftmailer_test/swiftmailer_test.module
Alter messages before sending it with SwiftMailer.
1 invocation of hook_swiftmailer_alter()
SwiftMailer::mail in src/Plugin/Mail/SwiftMailer.php
Sends a message composed by drupal_mail().

File

./swiftmailer.api.php, line 18
Hooks specific to the SwiftMailer module.

Code

function hook_swiftmailer_alter(Swift_Mailer &$swiftMailer, Swift_Message &$swiftMessage, $message) {

  // Set read receipt.
  $swiftMessage
    ->setReadReceiptTo([
    'your@address.com',
  ]);

  // Register a SwiftMailer Plugin.
  // @see https://swiftmailer.symfony.com/docs/plugins.html
  $replacements = [];
  $decorator = new Swift_Plugins_DecoratorPlugin($replacements);
  $swiftMailer
    ->registerPlugin($decorator);
}