Mailwizz, глобальное исключение доменов получателей

Задача: заблокировать отправку на определённые доменные зоны получателей.

Решение:

1 — в файле apps/init-custom.php добавьте следующий код:

<?php

Yii::app()->hooks->addFilter('email_blacklist_is_email_blacklisted', function($isBlacklisted, $email, $subscriber = null, $customer = null, array $params = []){
    // if already blacklisted we stop
    if ($isBlacklisted !== false) {
        return $isBlacklisted;
    }

    // Load the file with domains in memory, just once per request.
    // If your file size is 10mb, you will need 10mb ram to hold this file
    // This is not effective at all, but if the file is small, it will work just fine
    static $domains;
    if ($domains === null) {
        $domains = [];
        if (is_file(__DIR__ . '/blacklist-domains.txt')) {
            $domains = array_map('strtolower', explode(PHP_EOL, (string)file_get_contents(__DIR__ . '/blacklist-domains.txt')));
        }
    }

    // get the domain from the email address
    list(, $domain) = explode('@', $email);

    // search the domain inside the domains file
    if (array_search(strtolower($domain), $domains) !== false) {
        $isBlacklisted = 'This email address is blacklisted because the domain it belongs to is blacklisted!';
    }

    return $isBlacklisted;
});

2 — добавьте в папку /apps/ файл с именем «blacklist-domains.txt», который содержит все домены, по одному в каждой строке.

0

my-mails.ru

Всегда On-Line

Авторизация
*
*

Капча загружается...


Регистрация
*
*
*
*

Капча загружается...


Генерация пароля

Капча загружается...


51276208