-1

I am using lumen framework ,which is micro framework of laravel I have to create cron for sent email, I have put my file in app/console/commands

register my command in kernel.php file

it is working fine, I have checked it

now in file have call the code of model which is below for sent email,

$sent = Mail::send(['html' => 'email_render'], ['html' => $data["body"]], function ($msg) use ($data) {
            $msg->from($data["from_address"])
            ->to($data["to_address"])->subject($data["subject"]);//->setBody($data["body"]);
            if (isset($data["cc_address"]) && $data["cc_address"]) {
                $msg->cc($data["cc_address"]);
            }
            if (isset($data["bcc_address"]) && $data["bcc_address"]) {
                $msg->bcc($data["bcc_address"]);
            }
            if (isset($data["attachment"]) && $data["attachment"]) {
                foreach ($data["attachment"] as $attachment) {
                    $msg->attach($attachment['file'], $attachment['options']);
                }
            }
            if (isset($data["message_id"]) && $data["message_id"] && $data["type"] != "compose") {
                $msg->getSwiftMessage()->getHeaders()->addTextHeader("In-Reply-To", "<".$data["message_id"].">");
                $msg->getSwiftMessage()->getHeaders()->addTextHeader("References", self::getReferances($data));
            }
        });

it is giving me error as below,

[RuntimeException]                                                         ←[39;49m
←[37;41m  No supported encrypter found. The cipher and / or key length are invalid. 

the same model function if I call it from controller then it is working but call it from command then it is giving me error,

any reason for that ?

I got my solution,

in lumen framework , I am not able to generate key with use of command

artisan key:generate

Solution

I have generate it with use of below url,

Lumen Micro Framework => php artisan key:generate

then run my command it is sending emails,

BUT not sure why it was working with controller before and not working with command.

parisssss
  • 803
  • 16
  • 36
hetal gohel
  • 335
  • 9
  • 21

1 Answers1

1

That is happening because the cipher you are using is expecting another sized string than you have in your setup.

If you are using a 16 character string in your config (SomeRandomString) then you can change it to use the cipher AES-128-CBC.

BUT I would recommend you to run the artisan command (from your command line) php artisan key:generate

  • php artisan key:generate , this command is not working with lumen, it is problem occur while send email from cron, while use same code with controller it is working fine – hetal gohel Nov 29 '18 at 09:28