Skip to content

Commit

Permalink
Adjust mailer to add debug information to Symfony mailer
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot authored Feb 12, 2022
1 parent bcd2be6 commit 7d10c0b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public function send($view, array $data = [], $callback = null)

protected function applyDebugHeaders(Mailable $mailable)
{
$mailable->withSwiftMessage(function (\Swift_Message $swiftMessage) use ($mailable) {
$methodName = method_exists($mailable, 'withSymfonyMessage') ? 'withSymfonyMessage' : 'withSwiftMessage';

$mailable->$methodName(function ($message) use ($mailable) {
$viewFile = $view = $viewContent = $viewData = null;

$viewFile = $this->getMailableViewFile($mailable);
Expand All @@ -42,7 +44,7 @@ protected function applyDebugHeaders(Mailable $mailable)
* We need to base64 encode the data, as the SMTP header mime encoding could add unwanted
* CLRF line breaks.
*/
$headers = $swiftMessage->getHeaders();
$headers = $message->getHeaders();
$headers->addTextHeader('X-HELO-View', base64_encode($viewContent));
$headers->addTextHeader('X-HELO-View-File', base64_encode($viewFile));
$headers->addTextHeader('X-HELO-View-Data', base64_encode($viewData));
Expand Down

0 comments on commit 7d10c0b

Please sign in to comment.