function DevelMailLog::mail

Same name in other branches
  1. 7.x-1.x devel.mail.inc \DevelMailLog::mail()
  2. 4.x src/Plugin/Mail/DevelMailLog.php \Drupal\devel\Plugin\Mail\DevelMailLog::mail()

Overrides MailInterface::mail

File

src/Plugin/Mail/DevelMailLog.php, line 79

Class

DevelMailLog
Defines a mail backend that saves emails as temporary files.

Namespace

Drupal\devel\Plugin\Mail

Code

public function mail(array $message) : bool {
    $directory = $this->config
        ->get('debug_mail_directory');
    if (!$this->prepareDirectory($directory)) {
        return FALSE;
    }
    $pattern = $this->config
        ->get('debug_mail_file_format');
    $filename = $this->replacePlaceholders($pattern, $message);
    $output = $this->composeMessage($message);
    return (bool) file_put_contents($directory . '/' . $filename, $output);
}