From 213a370b703592587bafcd52d38a0ad772ff7442 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 10 Jul 2024 20:56:33 +0100 Subject: [PATCH] [11.x] Allow view content dependent mail callbacks (#51990) * Allow view content dependent mail callbacks * Update Mailer.php --------- Co-authored-by: Max Tingle Co-authored-by: Taylor Otwell --- src/Illuminate/Mail/Mailer.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Illuminate/Mail/Mailer.php b/src/Illuminate/Mail/Mailer.php index 685eaa3118f6..85029d959b40 100755 --- a/src/Illuminate/Mail/Mailer.php +++ b/src/Illuminate/Mail/Mailer.php @@ -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.