diff --git a/Esp.cf b/Esp.cf index 2a99fa3..7aa2372 100644 --- a/Esp.cf +++ b/Esp.cf @@ -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 diff --git a/Esp.pm b/Esp.pm index ee9405b..912a937 100644 --- a/Esp.pm +++ b/Esp.pm @@ -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: @_"); } @@ -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; } @@ -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 @@ -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 @@ -182,6 +191,9 @@ MAILDOMEID =item * MAILCHIMPID +=item * +CONSTANTCONTACTID + =back =cut @@ -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); } @@ -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 { @@ -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; diff --git a/man/man3p/Mail::SpamAssassin::Plugin::Esp.3p b/man/man3p/Mail::SpamAssassin::Plugin::Esp.3p index 8872212..d3e6bb4 100644 --- a/man/man3p/Mail::SpamAssassin::Plugin::Esp.3p +++ b/man/man3p/Mail::SpamAssassin::Plugin::Esp.3p @@ -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: .\" ======================================================================== @@ -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 @@ -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" @@ -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 @@ -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