为什么管道电子邮件到laravel命令不起作用?

I'm trying to pipe email in Cpanel to Laravel 5.8 command but something is wrong:

first of all I used this code to find the executable path of php:

echo exec('which php'); // returns "/usr/local/bin/php"

and I added the forwarder in cpanel to:

/usr/local/bin/php -q /home/abcd10/public_html/laravelapp/artisan emailparse 

the laravel artisan command:

<?php

namespace App\Console\Commands;

use Illuminate\Support\Facades\Storage;
use Illuminate\Console\Command;
use Illuminate\Support\Str;
use Carbon;

class EmailParserCommand extends Command
{

    protected $signature = 'emailparse';

    protected $description = 'Parse an incomming email.';

    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {

        \DB::transaction(function () {  



            //$path = 'C:\Users\medoa\Desktop\email.eml'; // I used this to test the code in the localhost and it works manually
            $parser = new \PhpMimeMailParser\Parser();

            // Specify a stream to work with mail server (stream)
            $parser->setStream(fopen("php://stdin", "r"));

            $rawHeaderTo = $parser->getHeader('to');
            $rawHeaderFrom = $parser->getHeader('from');
            $arrayHeaderFrom = $parser->getAddresses('from');

            $subject = $parser->getHeader('subject');
            $body = $parser->getMessageBody('text');

            $upload = new \App\upload;
            $upload->from = $arrayHeaderFrom[0]['address'];
            $upload->subject = $subject;
            $upload->body = $body;
            $upload->save();

            $attachments = $parser->getAttachments();

            foreach ($attachments as $attachment)
             {
             $newfilename = Carbon\Carbon::now()->format('dmY') . Str::random(25) . $fileext;
      Storage::disk('public')->put('uploads/'.$newfilename, $attachment->getContent());

                $attobj = new \App\attachement;
                $attobj->filename = $newfilename;
                $attobj->original_filename = $attachment->getFilename();
                $attobj->upload_id = $upload->id;
                $attobj->size = Storage::disk('public')->size('uploads/'.$newfilename);
                $attobj->type = str_replace('.','',$fileext) ;

                $attobj->save();
            }
        });
    }   
}

I tested the code manually on the local host using this command "php artisan emailparse" using a locally stored file path and it works but I'm not sure whats wrong with what I did on the cpanel hosting.

the sender always recieve the follwing reply and nothing happens on the database:

This message was created automatically by mail delivery software. A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed: pipe to |/home/itrade10/public_html/metastockdata/artisan emailparse generated by upload@metastockdata.itradegame.com local delivery failed

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题