Skip to content

Commit

Permalink
Add support for Constant Contact Esp
Browse files Browse the repository at this point in the history
  • Loading branch information
bigio committed Mar 16, 2021
1 parent 4e0ac55 commit 36131a4
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Esp.cf
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,11 @@ header MAILCHIMP eval:esp_mailchimp_check()
describe MAILCHIMP Message from Mailchimp abused account
score MAILCHIMP 5.0

# -------- CONSTANTCONTACT --------
constantcontact_feed /etc/mail/spamassassin/constantcontact_id.txt

header CONSTANTCONTACT eval:esp_constantcontact_check()
describe CONSTANTCONTACT Message from Constant Contact abused account
score CONSTANTCONTACT 5.0

endif # Mail::SpamAssassin::Plugin::Esp
54 changes: 53 additions & 1 deletion Esp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use Mail::SpamAssassin::PerMsgStatus;
use vars qw(@ISA);
our @ISA = qw(Mail::SpamAssassin::Plugin);

my $VERSION = 1.2.1;
my $VERSION = 1.3.0;

sub dbg { Mail::SpamAssassin::Plugin::dbg ("Esp: @_"); }

Expand All @@ -63,6 +63,7 @@ sub new {
$self->register_eval_rule('esp_mailup_check', $Mail::SpamAssassin::Conf::TYPE_HEAD_EVALS);
$self->register_eval_rule('esp_maildome_check', $Mail::SpamAssassin::Conf::TYPE_HEAD_EVALS);
$self->register_eval_rule('esp_mailchimp_check', $Mail::SpamAssassin::Conf::TYPE_HEAD_EVALS);
$self->register_eval_rule('esp_constantcontact_check', $Mail::SpamAssassin::Conf::TYPE_HEAD_EVALS);

return $self;
}
Expand Down Expand Up @@ -104,6 +105,9 @@ Usage:
esp_sendgrid_check_domain()
Checks for Sendgrid domains abused accounts
esp_constantcontact_check()
Checks for Constant Contact id abused accounts
=head1 ADMINISTRATOR SETTINGS
=over 4
Expand Down Expand Up @@ -142,6 +146,11 @@ Files can be separated by a comma.
A list of files with abused Mailchimp accounts.
Files can be separated by a comma.
=item constantcontact_feed [...]
A list of files with abused Constant Contact accounts.
Files can be separated by a comma.
=back
=head1 TEMPLATE TAGS
Expand Down Expand Up @@ -182,6 +191,9 @@ MAILDOMEID
=item *
MAILCHIMPID
=item *
CONSTANTCONTACTID
=back
=cut
Expand Down Expand Up @@ -226,6 +238,12 @@ sub set_config {
type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING,
}
);
push(@cmds, {
setting => 'constantcontact_feed',
is_admin => 1,
type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING,
}
);
$conf->{parser}->register_commands(\@cmds);
}

Expand All @@ -237,6 +255,7 @@ sub finish_parsing_end {
$self->_read_configfile('mailup_feed', 'MAILUP');
$self->_read_configfile('maildome_feed', 'MAILDOME');
$self->_read_configfile('mailchimp_feed', 'MAILCHIMP');
$self->_read_configfile('constantcontact_feed', 'CONSTANTCONTACT');
}

sub _read_configfile {
Expand Down Expand Up @@ -458,5 +477,38 @@ sub esp_mailchimp_check {
}
}

}

sub esp_constantcontact_check {
my ($self, $pms) = @_;
my $contact_id;

my $rulename = $pms->get_current_eval_rule_name();

# return if X-Mailer is not what we want
my $xmailer = $pms->get("X-Mailer", undef);

if((not defined $xmailer) or ($xmailer !~ /Roving\sConstant\sContact/)) {
return;
}

my $envfrom = $pms->get("EnvelopeFrom:addr", undef);
return if not defined $envfrom;
return if $envfrom !~ /\@in\.constantcontact\.com/;

$contact_id = $pms->get("X-Roving-Id", undef);
return if not defined $contact_id;

chomp($contact_id);
if(defined $contact_id) {
if ( exists $self->{ESP}->{CONSTANTCONTACT}->{$contact_id} ) {
$pms->set_tag('CONSTANTCONTACTID', $contact_id);
dbg("HIT! $contact_id customer found in Constant Contact feed");
$pms->test_log("Constant Contact id: $contact_id");
$pms->got_hit($rulename, "", ruletype => 'eval');
return 1;
}
}

}
1;
13 changes: 11 additions & 2 deletions man/man3p/Mail::SpamAssassin::Plugin::Esp.3p
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40)
.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
.\"
.\" Standard preamble:
.\" ========================================================================
Expand Down Expand Up @@ -133,7 +133,7 @@
.\" ========================================================================
.\"
.IX Title "Esp 3"
.TH Esp 3 "2021-02-11" "perl v5.32.1" "User Contributed Perl Documentation"
.TH Esp 3 "2021-03-16" "perl v5.32.1" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
Expand Down Expand Up @@ -187,6 +187,9 @@ Usage:
\&
\& esp_sendgrid_check_domain()
\& Checks for Sendgrid domains abused accounts
\&
\& esp_constantcontact_check()
\& Checks for Constant Contact id abused accounts
.Ve
.SH "ADMINISTRATOR SETTINGS"
.IX Header "ADMINISTRATOR SETTINGS"
Expand Down Expand Up @@ -218,6 +221,10 @@ Files can be separated by a comma.
.IX Item "mailchimp_feed [...]"
A list of files with abused Mailchimp accounts.
Files can be separated by a comma.
.IP "constantcontact_feed [...]" 4
.IX Item "constantcontact_feed [...]"
A list of files with abused Constant Contact accounts.
Files can be separated by a comma.
.SH "TEMPLATE TAGS"
.IX Header "TEMPLATE TAGS"
.RS 4
Expand Down Expand Up @@ -247,3 +254,5 @@ Tags that the plugin could set are:
\&\s-1MAILDOMEID\s0
.IP "\(bu" 4
\&\s-1MAILCHIMPID\s0
.IP "\(bu" 4
\&\s-1CONSTANTCONTACTID\s0

0 comments on commit 36131a4

Please sign in to comment.