|
- <?php
-
- namespace App\Console\Commands;
-
- use App\Files\TmpFile;
- use App\Logic\EmailManager;
- use App\Email\Test;
-
- class TestEmail extends BaseCommand
- {
-
- const COMMAND = "mail:test {email}";
-
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = self::COMMAND;
-
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'テストメールを送信する(キュー登録)';
-
- static public function getCommand()
- {
- return self::COMMAND;
- }
-
-
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
-
- /**
- * Execute the console command.
- *
- * @return int
- */
- public function service(): int
- {
- $email = $this->argument('email');
-
- $file = new TmpFile();
- $file->put("iwabuchi text");
-
-
- $mailer = new Test();
- $mailer->setEmail($email);
-
- $manager = new EmailManager($mailer);
- $manager
- ->attach($file->getFullPath(), "test.txt", "text/plain")
- ->confirm();
-
- return self::RESULTCODE_SUCCESS;
- }
- }
|