You are here

public function Mailer::send in Backup and Migrate 8.4

Parameters

string|array $to: An RFC 2822 formatted to string or an array of them.

string $subject: The subject of the email to be sent.

string $body: The body of the message being sent.

array $replacements: An array of string replacements for both the body and the subject.

array $additional_headers: Additional headers to be added to the email if any.

Return value

mixed

Overrides MailerInterface::send

File

lib/backup_migrate_core/src/Service/Mailer.php, line 19

Class

Mailer
Class Mailer.

Namespace

BackupMigrate\Core\Service

Code

public function send($to, $subject, $body, $replacements = [], $additional_headers = []) {

  // Combine the to objects.
  if (is_array($to)) {
    $to = implode(',', $to);
  }

  // Do the string replacement.
  if ($replacements) {
    $subject = strtr($subject, $replacements);
    $body = strtr($body, $replacements);
  }

  // Use the PHP mail function to send the message.
  mail($to, $subject, $body, $additional_headers);
}