Domains.pm 1.71 KB
Newer Older
1
2
3
4
5
6
# -*- indent-tabs-mode: nil; -*-
# vim:ft=perl:et:sw=4
# $Id$

# Sympa - SYsteme de Multi-Postage Automatique
#
7
8
9
# Copyright 2019 The Sympa Community. See the AUTHORS.md file at
# the top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

package Sympa::Tools::Domains;

use strict;
use warnings;
use Conf;
use Sympa::Tools::Text;

31
sub is_blocklisted {
32
33
    my $email = shift;

34
    if (defined($Conf::Conf{'domains_blocklist'})) {
35
        my @parts = split '@', Sympa::Tools::Text::canonic_email($email);
36
        foreach my $f (split ',', lc($Conf::Conf{'domains_blocklist'})) {
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
            if ($parts[1] && $parts[1] eq $f) {
                return 1;
            }
        }
    }

    return 0;
}

1;
__END__

=encoding utf-8

=head1 NAME

Sympa::Tools::Domains - Domains-related functions

=head1 DESCRIPTION

This package provides some email's domains-related functions.

=head2 Functions

=over

63
=item is_blocklisted ( $email )
64

65
Says if the domain of the given email is blocklisted (C<domains_blocklist>
66
67
setting).

68
Returns 1 if it's blocklisted, 0 otherwise
69
70
71
72

=back

=cut