Serialization of closure failed: The closure was not found within the abstract syntax tree
<p>I am receiving this error in production but not in local testing:</p>

<blockquote>
  <p>Serialization of closure failed: The closure was not found within the abstract syntax tree.</p>
</blockquote>

<p>I use Homestead/Vagrant on my local machine to ensure the environment is similar to production and I cannot track down why I started receiving this in production when I did not receive it at all in local testing.</p>

<p>The snippet of code is below, any thoughts are greatly appreciated.</p>

<pre class="lang-php prettyprint-override"><code>foreach ($notifications as $notification) {
    $data = array('eventInfo' =&gt; $eventInfo, 'bowlerInfo' =&gt; $bowlerInfo, 'bowlerSchoolInfo' =&gt; $bowlerSchoolInfo,
        'matchInfo' =&gt; $match, 'notificationInfo' =&gt; $notification);

    Mail::queue('emails.matchEventAddedNotification', $data, function ($message) use ($notification, $bowlerInfo) {

        $dataHeader['category'] = 'Match Event Notification';
        $dataHeader['unique_args']['message'] = 'Email related to a new match event notification.';
        $dataHeader['unique_args']['bowler_id'] = $bowlerInfo['id'];
        $dataHeader['unique_args']['matchevents_notify_id'] = $notification['id'];
        $header = json_encode($dataHeader);
        $message-&gt;getSwiftMessage()-&gt;getHeaders()-&gt;addTextHeader('X-SMTPAPI', $header);
        $message-&gt;subject('New Score Added For' . ' ' . $bowlerInfo['first_name'] . ' ' . $bowlerInfo['last_name']);
        $message-&gt;to($notification['email']);
    });

    $matcheventNotify = Matchevent_Notify::find($notification['id']);
    $matcheventNotify-&gt;last_sent = Carbon::now();
    $matcheventNotify-&gt;save();
}
</code></pre>

<p>Production Environment</p>

<pre><code>APP_ENV=production
APP_DEBUG=false
APP_KEY=XXXXX

DB_HOST=localhost
DB_DATABASE=klaabowling
DB_USERNAME=XXXXXXX
DB_PASSWORD=XXXXXXX

CACHE_DRIVER=file
SESSION_DRIVER=file

DOMAIN_BASE=klaabowling.com
APP_URL=http://klaabowling.com

AWS_REGION=us-west-2
AWS_AccessKey=XXXXXX
AWS_SecretAccessKey=XXXXXX

GOOGLE_MAPS_API_KEY=XXXXXX
</code></pre>