您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

30 行
883B

  1. <?php
  2. namespace common\components\BulkMailer;
  3. use domain\Communication\Email\Email;
  4. use domain\Setting\AdminSettingBag;
  5. use yii\base\ErrorException;
  6. class BulkMailerProxy implements BulkMailerInterface
  7. {
  8. public function getBulkMailer(): BulkMailerInterface
  9. {
  10. $bulkMailerSetting = AdminSettingBag::getInstance()->get('bulkMailer');
  11. if($bulkMailerSetting == BulkMailerInterface::MAILJET) {
  12. return new BulkMailerMailjet();
  13. }
  14. elseif($bulkMailerSetting == BulkMailerInterface::BREVO) {
  15. return new BulkMailerBrevo();
  16. }
  17. else {
  18. throw new ErrorException("Le mailer pour les emails en masse n'est pas défini dans les paramètres admin.");
  19. }
  20. }
  21. public function sendEmail(Email $email, array $usersArray)
  22. {
  23. $this->getBulkMailer()->sendEmail($email, $usersArray);
  24. }
  25. }