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 App的会员连续扣费
  • ¥15 不同数据类型的特征融合应该怎么做
  • ¥15 用proteus软件设计一个基于8086微处理器的简易温度计
  • ¥15 用联想小新14Pro
  • ¥15 multisim中关于74ls192n和DSWPK开关仿真图分析(减法计数器)
  • ¥15 基于8255的交通灯设计
  • ¥15 w3wp,exe 中发生未处理的 Microsoft ,NETFramework 异常。
  • ¥20 C51单片机程序及仿真(加减器)
  • ¥15 AQWA | 水动力分析 二阶波浪力
  • ¥15 c语言题目:成绩管理系统