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.