-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Mail subject does not work when using queue:work #41240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Which mail driver? You'll need to share your code for the mailable class and the The below example shows the expected email subject line is correctly set for both commands App\Mail\Foo.phpnamespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class Foo extends Mailable
{
use Queueable, SerializesModels;
public function build()
{
return $this->subject('foo')->view('mail.foo');
}
} resources/views/mail/foo.blade.phpbar .env
Laravel TinkerMail::to('baz@example.com')->queue(new App\Mail\Foo); command lineRun storage/logs/laravel.logThis email header/body is logged using both commands.
Keep in mind if you're using use App\Mail\Foo;
Mail::fake();
Mail::to('baz@example.com')->queue(new Foo);
// this fails
Mail::assertQueued(Foo::class, function ($mail) {
// build() hasn't been called so the subject isn't filled yet
return $mail->subject === 'foo';
});
// this passes
Mail::assertQueued(Foo::class, function ($mail) {
return $mail->build()->subject === 'foo';
}); |
Hi there, Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels: However, this issue will not be locked and everyone is still free to discuss solutions to your problem! Thanks. |
Thanks @derekmd |
Description:
I just experienced a problem where for no reason the subject of my emails was not being sent. Googling i found this resource:
https://stackoverflow.com/questions/61836901/laravel-mailable-subject-not-working-if-i-queue-the-mailable
Where it was stated that the problem could be solved by using queue:listen instead of queue:work. Is there an specific reason for why mail subject shouldn't work when using queue:work especially since it is known to have better performance than queue:listen?
The text was updated successfully, but these errors were encountered: