dongtiao2105 2018-07-16 16:04
浏览 105

分段错误(核心转储)Laravel SwiftMailer

I'm having problem when using SwiftMailer Laravel 5.2. I have a controller for sending email and I set it to run every minute. When I execute my script below with php artisan schedule:run, its keeps return an error message 'Segmentation fault (core dumped)'.

My script:

public static function sendMailCoc()
{
    $mail_log = MailLog::where('status', '!=', 'SENT')->where('type', '3')->orderBy('id', 'asc')->get();
    foreach($mail_log as $mail){
        if($mail->to!='') {
            $coc = json_decode($mail->parameter, true);
            try {
                Mail::queue($mail->file_view,
                    ['to' => $mail->to_name,
                        'coc' => $coc,
                        'notif_id' => $mail->notification_id
                    ],
                    function ($message) use ($mail) {
                        $message->to($mail->to)
                            ->subject($mail->subject);
                    });
                $mail->status = 'SENT';
                $mail->error_message = '';
                $mail->save();
            }
            catch(Swift_TransportException $e){
                $mail->status = 'ERROR';
                $mail->error_message = $e->getMessage();
                $mail->save();
                continue;
            }catch (Exception $e) {
                $mail->status = 'ERROR';
                $mail->error_message = $e->getMessage();
                $mail->save();
                continue;
            }                    

        }
    }
}

Sometimes if I test to send just one email, it works and not return an error message. But when I try to send a lot of email with looping, its always get an error message "Segmentation fault (core dumped)". I'm using Ubuntu Server 14.04.

I don't know what is causing this error. It is my script that causing this problem, Laravel, or Ubuntu Linux?

Is there any way to solve this problem? What should I check first?

Thank you for your help and answer.

  • 写回答

1条回答 默认 最新

  • douou6807 2018-07-26 20:00
    关注

    Wild shot, but I've been debugging the same error message in relation to queued jobs recently:

    As per Laravel 5.6 documentation (https://laravel.com/docs/5.6/queues#creating-jobs):

    "Binary data, such as raw image contents, should be passed through the base64_encode function before being passed to a queued job. Otherwise, the job may not properly serialize to JSON when being placed on the queue."

    My problem was resolved (almost!) as soon as I added base64_encode($input) in constructor and base64_decode($this->input) in handle() function.

    PS: Since I was using two distributed apps for input and working on the queue, I also had to run composer dump-autoload and php artisan cache:clear on both apps, while also restarting the supervisor worker, after making the code change.

    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵