|
- <?php
-
- namespace common\components\BulkMailer;
-
- use domain\Setting\AdminSettingBag;
- use yii\base\ErrorException;
-
- class BulkMailerProxy implements BulkMailerInterface
- {
- public function getBulkMailer(): BulkMailerInterface
- {
- $bulkMailerSetting = AdminSettingBag::getInstance()->get('bulkMailer');
-
- if($bulkMailerSetting == BulkMailerInterface::MAILJET) {
- return new BulkMailerMailjet();
- }
- elseif($bulkMailerSetting == BulkMailerInterface::BREVO) {
- return new BulkMailerBrevo();
- }
- else {
- throw new ErrorException("Le mailer pour les emails en masse n'est pas défini dans les paramètres admin.");
- }
- }
-
- public function sendEmails(array $contactsArray, string $fromName, string $fromEmail, string $subject, string $htmlContent, string $textContent = null)
- {
- $this->getBulkMailer()->sendEmails($contactsArray, $fromName, $fromEmail, $subject, $htmlContent, $textContent);
- }
- }
|