最終更新日:2021.02.12
EC-CUBE3系で商品の注文確定メールを複数の宛先に送る方法です。
ディレクトリsrc→Eccube→Service
内
MailService.php
以下の様に234行目あたり「受注メール送信開始」部分を変更します。
public function sendOrderMail(\Eccube\Entity\Order $Order)
{
log_info('受注メール送信開始');
$MailTemplate = $this->app['eccube.repository.mail_template']->find(1);
$body = $this->app->renderView($MailTemplate->getFileName(), array(
'header' => $MailTemplate->getHeader(),
'footer' => $MailTemplate->getFooter(),
'Order' => $Order,
));
$message = \Swift_Message::newInstance()
->setSubject('[' . $this->BaseInfo->getShopName() . '] ' . $MailTemplate->getSubject())
->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
->setTo(array($Order->getEmail()))
->setBcc($this->BaseInfo->getEmail01())
->setReplyTo($this->BaseInfo->getEmail03())
->setReturnPath($this->BaseInfo->getEmail04())
->setBody($body);
$event = new EventArgs(
array(
'message' => $message,
'Order' => $Order,
'MailTemplate' => $MailTemplate,
'BaseInfo' => $this->BaseInfo,
),
null
);
$this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_ORDER, $event);
$count = $this->app->mail($message);
log_info('受注メール送信完了', array('count' => $count));
return $message;
}
コピー
public function sendOrderMail(\Eccube\Entity\Order $Order)
{
log_info('受注メール送信開始');
$MailTemplate = $this->app['eccube.repository.mail_template']->find(1);
$body = $this->app->renderView($MailTemplate->getFileName(), array(
'header' => $MailTemplate->getHeader(),
'footer' => $MailTemplate->getFooter(),
'Order' => $Order,
));
$message = \Swift_Message::newInstance()
->setSubject('[' . $this->BaseInfo->getShopName() . '] ' . $MailTemplate->getSubject())
->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
->setTo(array($Order->getEmail()))
->setBcc(array($this->BaseInfo->getEmail01(),'test@test.co.jp','test2@test.jp','osaka@test.co.jp','test@gmail.com'))
->setReplyTo($this->BaseInfo->getEmail03())
->setReturnPath($this->BaseInfo->getEmail04())
->setBody($body);
$event = new EventArgs(
array(
'message' => $message,
'Order' => $Order,
'MailTemplate' => $MailTemplate,
'BaseInfo' => $this->BaseInfo,
),
null
);
$this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_ORDER, $event);
$count = $this->app->mail($message);
log_info('受注メール送信完了', array('count' => $count));
return $message;
}
コンマで区切ることで何個でもアドレスを増やせます!
他にも「受注管理通知メール」「会員登録完了メール」「退会手続き完了メール」「仮会員登録再送メール」「注管理通知メール」も同じです。