| @@ -3,6 +3,7 @@ | |||||
| namespace App\Email; | namespace App\Email; | ||||
| use App\Exceptions\AppCommonException; | use App\Exceptions\AppCommonException; | ||||
| use App\Exceptions\TempFileNotExistsException; | |||||
| use App\Models\Email; | use App\Models\Email; | ||||
| use App\Models\EmailAttachment; | use App\Models\EmailAttachment; | ||||
| use App\Models\User; | use App\Models\User; | ||||
| @@ -82,7 +83,17 @@ abstract class BaseEmailer extends Mailable | |||||
| if ($this->__attachments !== null) { | if ($this->__attachments !== null) { | ||||
| $count = $this->__attachments->count(); | $count = $this->__attachments->count(); | ||||
| foreach ($this->__attachments as $attachment) { | foreach ($this->__attachments as $attachment) { | ||||
| $filepath = $attachment->filepath; | $filepath = $attachment->filepath; | ||||
| if (!file_exists($filepath)) { | |||||
| $e = new TempFileNotExistsException(); | |||||
| throw $e->setFilepath($filepath); | |||||
| } | |||||
| $as = $attachment->send_filename; | $as = $attachment->send_filename; | ||||
| $mime = $attachment->mime; | $mime = $attachment->mime; | ||||
| $this->attach($filepath, [ | $this->attach($filepath, [ | ||||
| @@ -0,0 +1,21 @@ | |||||
| <?php | |||||
| namespace App\Exceptions; | |||||
| use Exception; | |||||
| class TempFileNotExistsException extends Exception | |||||
| { | |||||
| private $filepath = ""; | |||||
| public function setFilepath(string $filepath): static | |||||
| { | |||||
| $this->filepath = $filepath; | |||||
| return $this; | |||||
| } | |||||
| public function getFilepath(): string | |||||
| { | |||||
| return $this->filepath; | |||||
| } | |||||
| } | |||||
| @@ -4,8 +4,10 @@ namespace App\Jobs\Email; | |||||
| use App\Codes\QueueName; | use App\Codes\QueueName; | ||||
| use App\Email\Sender; | use App\Email\Sender; | ||||
| use App\Exceptions\TempFileNotExistsException; | |||||
| use App\Jobs\BaseJob; | use App\Jobs\BaseJob; | ||||
| use App\Models\Email; | use App\Models\Email; | ||||
| use Illuminate\Support\Facades\Log; | |||||
| class SimpleEmail extends BaseJob | class SimpleEmail extends BaseJob | ||||
| { | { | ||||
| @@ -29,6 +31,11 @@ class SimpleEmail extends BaseJob | |||||
| */ | */ | ||||
| public function handle() | public function handle() | ||||
| { | { | ||||
| Sender::send($this->emailId); | |||||
| try { | |||||
| Sender::send($this->emailId); | |||||
| } catch (TempFileNotExistsException $e) { | |||||
| // 一時ファイルが存在しないため、処理終了 | |||||
| Log::warning(sprintf("ファイル存在しないため、メール送信処理スキップ :%s", $e->getFilepath())); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||