Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mkrell's avatar

Laravel 5.5 won't render email with PHP 7.4

I am trying to render an email in Laravel 5.5, but no matter what I do, I get the following error on render:

ErrorException (E_NOTICE) Trying to access array offset on value of type null

happens in \vendor\egulias\email-validator\EmailValidator\Parser\Parser.php

I am running php 7.4 and I believe the error does NOT happen on php 7.3.

web.php:

Route::get('scratch', function(){
  $mail = new Test();
  return $mail->render();
});

Test.php

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class Test extends Mailable
{
  use Queueable, SerializesModels;

  public $subscription;

  /**
   * Create a new message instance.
   *
   * @return void
   */
  public function __construct()
  {
  }

  /**
   * Build the message.
   *
   * @return $this
   */
  public function build()
  {
    return $this->view('emails.test');
  }
}

test.blade.php

Hello from world

I'm thinking this has to be an issue with Laravel 5.5 and PHP 7.4. I can change my version but I'd like to avoid that if possible. Upgrading Laravel won't work for this application.

0 likes
3 replies
Snapey's avatar

who are you sending the mail to?

mkrell's avatar

Nobody, just trying to render it. Do you have to set the to before render will work?

mkrell's avatar
mkrell
OP
Best Answer
Level 1

@snapey looks like a composer update fixed it. I'm always nervous of that solution on legacy apps but whatever lol

Please or to participate in this conversation.