領収証発行サービス
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.2KB

  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Files\TmpFile;
  4. use App\Logic\EmailManager;
  5. use App\Email\Test;
  6. class TestEmail extends BaseCommand
  7. {
  8. const COMMAND = "mail:test {email}";
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = self::COMMAND;
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = 'テストメールを送信する(キュー登録)';
  21. static public function getCommand()
  22. {
  23. return self::COMMAND;
  24. }
  25. /**
  26. * Create a new command instance.
  27. *
  28. * @return void
  29. */
  30. public function __construct()
  31. {
  32. parent::__construct();
  33. }
  34. /**
  35. * Execute the console command.
  36. *
  37. * @return int
  38. */
  39. public function service(): int
  40. {
  41. $email = $this->argument('email');
  42. $file = new TmpFile();
  43. $file->put("iwabuchi text");
  44. $mailer = new Test();
  45. $mailer->setEmail($email);
  46. $manager = new EmailManager($mailer);
  47. $manager
  48. ->attach($file->getFullPath(), "test.txt", "text/plain")
  49. ->confirm();
  50. return self::RESULTCODE_SUCCESS;
  51. }
  52. }