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

devonmather's avatar

emailOutputOnFailure() on command executing every time in Vapor

Running Laravel: v7.7.1

In the app/Console/Kernel.php I have

protected function schedule(Schedule $schedule)
{
    $schedule->command(DailyCommand::class)
        ->dailyAt('01:00')
        ->emailOutputOnFailure('[email protected]');
}

Then i have an example command app/Console/Commands/DailyCommand.php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class DailyCommand extends Command
{
    protected $signature = 'daily:run';

    public function handle()
    {
        $var = 1 + 1;
    }
}

However I'm getting emails every day for the command with Subject "Scheduled Job Output For ['/opt/bin/php' 'artisan' daily:run]" and nothing in the content of the email. Vapor logs and Sentry.io show no errors.

Anyone have a similar issue, or advice on what could be wrong with the above code?

Thanks in advance 🙂

0 likes
4 replies
nunodonato's avatar

I'm running into this as well (laravel 6, here). Had to disable emailoutput :(

mbryne's avatar

I'll just add to this as I'm having the same issue.

It could be that Vapor commands pipe their output to null:

Running scheduled command: '/opt/bin/php' 'artisan' inspire > '/dev/null' 2>&1

This causes a Swift_TransportException because the email output is empty.

I unfortunately don't have a resolution to the issue and can't troubleshoot it further or submit a support ticket at this time.

Edit: just looking into this further, the following file appears to capture the output and pass it back to a Lambda response for any logged lines or above but I can't seem to view the output anywhere:

/vendor/laravel/vapor-core/src/Vapor/Runtime/Handlers/CliHandler.php

mbryne's avatar

Just thought I would post an update to this as I realied I had solved it in the interim.

After emailing Vapor support they had suggested to use the Logging facade for Jobs or Scheduled Tasks:

https://laravel.com/docs/8.x/logging

Hope that helps anybody who stumbles upon this.

1 like

Please or to participate in this conversation.