简体   繁体   中英

Laravel 8 doesn't send an email notification when notifications are set to job

I am trying to send a notification via email. Everything is fine as long as I don't want to do it on the job. When I add implements ShouldQueue to the notification class, the task fails with the error Swift_TransportException: Cannot send message without a sender address in C: \\ Users \\ (...) \\ vendor \\ swiftmailer \\ swiftmailer \\ lib \\ classes \\ Swift \\ Transport \\ AbstractSmtpTransport.php: 195

Of course env is ok, config (mail.from.address) sees what you need, which is confirmed by normal mailing and notifications when I am not trying to use job.

DefaultNotify.php

public function toMail($notifiable)
    {
        return (new MailMessage)
        ->line('The introduction to the notification.')
        ->action('Notification Action', url('/'))
        ->line('Thank you for using our application!');
}

I was tried add ->from('address@domain.com') , that was fine without job.

请检查您的 smtp 设置

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM