You are here

public function Mailer::send in Backup and Migrate 5.0.x

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

src/Core/Service/Mailer.php, line 18

Class

Mailer
A very basic mailer that uses the php mail function.

Namespace

Drupal\backup_migrate\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);
}