Browse Source

メール送信のBCC対応

master
sosuke.iwabuchi 1 year ago
parent
commit
38cfd4412d
2 changed files with 9 additions and 2 deletions
  1. +7
    -2
      app/Email/Sender.php
  2. +2
    -0
      config/mail.php

+ 7
- 2
app/Email/Sender.php View File

@@ -21,9 +21,14 @@ class Sender
'mailer' => $email->type, 'mailer' => $email->type,
]); ]);


$bcc = config('mail.bcc_targets', []);

try { try {
Mail::to($email->email)
->send(new TextEmail($email->subject, $email->content, $email->emailAttachments));
$send = Mail::to($email->email);
if (0 < count($bcc)) {
$send = $send->bcc($bcc);
}
$send->send(new TextEmail($email->subject, $email->content, $email->emailAttachments));
} catch (Exception $e) { } catch (Exception $e) {
Log::error("メール送信失敗", [ Log::error("メール送信失敗", [
'id' => $email->id, 'id' => $email->id,


+ 2
- 0
config/mail.php View File

@@ -125,4 +125,6 @@ return [


'developmentEmail' => env('MAIL_ADDRESS_DEVELOPMENT'), 'developmentEmail' => env('MAIL_ADDRESS_DEVELOPMENT'),


'bcc_targets' => explode(",", env('MAIL_BCC_TARGETS', '')),

]; ];

Loading…
Cancel
Save