<?php
/**
 * Created by PhpStorm.
 * User: zhl
 * Date: 2023/2/7
 * Time: 17:58
 */
namespace App\Console\Commands\Test;


use App\Helper\Arr;
use App\Helper\Translate;
use App\Mail\TextMail;
use App\Models\Blog\Blog;
use App\Models\Blog\BlogCategory;
use App\Models\Com\KeywordVideoTask;
use App\Models\Com\KeywordVideoTaskLog;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\CustomModule\CustomModuleExtentContent;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
use App\Models\ExtentModule\ExtensionModuleValue;
use App\Models\File\File;
use App\Models\File\File as FileModel;
use App\Models\File\Image;
use App\Models\File\Image as ImageModel;
use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\Project\AutoEmailLog;
use App\Models\Project\DeployOptimize;
use App\Models\Project\MinorLanguages;
use App\Models\Project\Project;
use App\Models\Purchaser\Purchaser;
use App\Models\Purchaser\PurchaserInfo;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
use App\Models\Template\BTemplateCom;
use App\Models\Template\Setting;
use App\Models\Template\Template;
use Hashids\Hashids;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Schema;


class Demo extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'demo';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'demo';

    public function handle(){
        return true;
    }


    public function toQueue(){
        $info = [
            'email' => '1123736022@qq.com', // 收件人邮箱
            'title' => '测试邮件',               // 邮件标题
            'content' => '这是来自163邮箱的测试邮件', // 邮件内容
        ];
        Config::set('mail.mailers.smtp.host', 'smtp.163.com');
        Config::set('mail.mailers.smtp.username', 'lyh103433@163.com');
        Config::set('mail.mailers.smtp.password', 'BMf8B327Nhncunnb');
        Config::set('mail.from.address', 'lyh103433@163.com');
        Config::set('mail.from.name', 'lyh');
        try {
            $status = AutoEmailLog::STATUS_SUCCESS;
            Mail::to([$info['email']])->send(new TextMail(['subject' => $info['title'], 'text' => $info['content']]));
        } catch (\Exception $e) {
            $status = AutoEmailLog::STATUS_ERROR;
            $this->output('任务:' . $info['id'] . ' 邮箱' . $info['email'] . '发送失败,' . $e->getMessage());
        }
        return $status;
    }

}