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

lyndon's avatar

Syntax error, unexpected token ")" when sending mail in laravel 8

I know the title seems familiar but hear me out...

My code works locally when I try to send out an invoice via email and the email gets sent. However, I deployed the same code to production on ec2 and got this error; https://i.stack.imgur.com/wQS48.jpg

my controller code looks like this...

public function invoice_send(Request $request, Invoice $invoice)
{
    Mail::to($request->to)->queue(new NewInvoice($invoice, $request));

    return redirect()->route('invoice.show', $invoice);
}

The vendor folder is the only thing that is different between production and development servers so I deleted the vendor and ran composer install again but that didn't solve anything.

Any ideas?

0 likes
6 replies
Sinnbeck's avatar

@lyndon Is the mail sent on a queue? If so, the cli might have a different php version

lyndon's avatar

@Sinnbeck I'm selecting this as the best answer because it pointed me in the right direction... the solution was to downgrade my PHP version from 8.1.8 to 8.0.21

Sinnbeck's avatar

@lyndon ok I assume that downgraded the package as well which fixed it :). Great that it worked

Please or to participate in this conversation.