Skip to content

Commit

Permalink
[11.x] Allow view content dependent mail callbacks (#51990)
Browse files Browse the repository at this point in the history
* Allow view content dependent mail callbacks

* Update Mailer.php

---------

Co-authored-by: Max Tingle <[email protected]>
Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
3 people authored Jul 10, 2024
1 parent 217789d commit 213a370
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/Illuminate/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,22 +303,19 @@ public function send($view, array $data = [], $callback = null)

$data['mailer'] = $this->name;

// First we need to parse the view, which could either be a string or an array
// containing both an HTML and plain text versions of the view which should
// be used when sending an e-mail. We will extract both of them out here.
// Once we have retrieved the view content for the e-mail we will set the body
// of this message using the HTML type, which will provide a simple wrapper
// to creating view based emails that are able to receive arrays of data.
[$view, $plain, $raw] = $this->parseView($view);

$data['message'] = $message = $this->createMessage();

// Once we have retrieved the view content for the e-mail we will set the body
// of this message using the HTML type, which will provide a simple wrapper
// to creating view based emails that are able to receive arrays of data.
$this->addContent($message, $view, $plain, $raw, $data);

if (! is_null($callback)) {
$callback($message);
}

$this->addContent($message, $view, $plain, $raw, $data);

// If a global "to" address has been set, we will set that address on the mail
// message. This is primarily useful during local development in which each
// message should be delivered into a single mail address for inspection.
Expand Down

0 comments on commit 213a370

Please sign in to comment.