diff --git a/Esp.cf b/Esp.cf index a86d513..e3f5d17 100644 --- a/Esp.cf +++ b/Esp.cf @@ -9,6 +9,8 @@ mailup_feed /etc/mail/spamassassin/mailup_id.txt maildome_feed /etc/mail/spamassassin/maildome_id.txt +mailchimp_feed /etc/mail/spamassassin/mailchimp_id.txt + # header SPBL_SENDGRID_ID eval:esp_sendgrid_check_id() # describe SPBL_SENDGRID_ID Message from Sendgrid abused account @@ -27,6 +29,9 @@ describe MAILUP Message from Mailup abused account header MAILDOME eval:esp_maildome_check() describe MAILDOME Message from Maildome abused account +header MAILCHIMP eval:esp_mailchimp_check() +describe MAILCHIMP Message from Mailchimp abused account + ifplugin Mail::SpamAssassin::Plugin::AskDNS askdns RBL_SENDGRID_ID _SENDGRIDID_.rblid.domain.tld A 127.0.0.2 describe RBL_SENDGRID_ID Invaluement Sendgrid Id blacklist diff --git a/Esp.pm b/Esp.pm index ec5f4b4..cfc6311 100644 --- a/Esp.pm +++ b/Esp.pm @@ -62,6 +62,7 @@ sub new { $self->register_eval_rule('esp_sendinblue_check', $Mail::SpamAssassin::Conf::TYPE_HEAD_EVALS); $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); # XXX Deprecated subs $self->register_eval_rule('sendgrid_check_domain', $Mail::SpamAssassin::Conf::TYPE_HEAD_EVALS); $self->register_eval_rule('sendgrid_check_id', $Mail::SpamAssassin::Conf::TYPE_HEAD_EVALS); @@ -88,6 +89,9 @@ endif Usage: + esp_mailchimp_check() + Checks for Mailchimp abused accounts + esp_maildome_check() Checks for Maildome abused accounts @@ -134,6 +138,10 @@ A file with abused Mailup accounts. A file with abused Maildome accounts. +=item mailchimp_feed [...] + +A file with abused Mailchimp accounts. + =back =head1 TEMPLATE TAGS @@ -171,6 +179,9 @@ MAILUPID =item * MAILDOMEID +=item * +MAILCHIMPID + =back =cut @@ -209,6 +220,12 @@ sub set_config { type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING, } ); + push(@cmds, { + setting => 'mailchimp_feed', + is_admin => 1, + type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING, + } + ); $conf->{parser}->register_commands(\@cmds); } @@ -219,6 +236,7 @@ sub finish_parsing_end { $self->_read_configfile('sendinblue_feed', 'SENDINBLUE'); $self->_read_configfile('mailup_feed', 'MAILUP'); $self->_read_configfile('maildome_feed', 'MAILDOME'); + $self->_read_configfile('mailchimp_feed', 'MAILCHIMP'); } sub _read_configfile { @@ -413,9 +431,8 @@ sub esp_maildome_check { if((not defined $xmailer) or ($xmailer !~ /MaildomeMTA/)) { return; } - # All Mailup emails have the X-Abuse header that must match - $maildome_id = $pms->get("List-Unsubscribe", undef); + $maildome_id = $pms->get("List-Unsubscribe", undef); return if not defined $maildome_id; $maildome_id =~ /subject=https:\/\/.*\/unsubscribe\/([0-9]+)\/([0-9]+)\/.*\/([0-9])\/([0-9]+)\>/; $maildome_id = $2; @@ -433,5 +450,34 @@ sub esp_maildome_check { } } +} + +sub esp_mailchimp_check { + my ($self, $pms) = @_; + my $mailchimp_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 !~ /MailChimp Mailer/)) { + return; + } + + $mailchimp_id = $pms->get("X-MC-User", undef); + return if not defined $mailchimp_id; + + chomp($mailchimp_id); + if(defined $mailchimp_id) { + if ( exists $self->{ESP}->{MAILCHIMP}->{$mailchimp_id} ) { + $pms->set_tag('MAILCHIMPID', $mailchimp_id); + dbg("HIT! $mailchimp_id customer found in Mailchimp feed"); + $pms->test_log("Mailchimp id: $mailchimp_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 997a8df..cafd3c5 100644 --- a/man/man3p/Mail::SpamAssassin::Plugin::Esp.3p +++ b/man/man3p/Mail::SpamAssassin::Plugin::Esp.3p @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "Esp 3" -.TH Esp 3 "2020-11-06" "perl v5.32.0" "User Contributed Perl Documentation" +.TH Esp 3 "2020-11-07" "perl v5.32.0" "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 @@ -167,6 +167,9 @@ endif Usage: .PP .Vb 2 +\& esp_mailchimp_check() +\& Checks for Mailchimp abused accounts +\& \& esp_maildome_check() \& Checks for Maildome abused accounts \& @@ -206,6 +209,9 @@ A file with abused Mailup accounts. .IP "maildome_feed [...]" 4 .IX Item "maildome_feed [...]" A file with abused Maildome accounts. +.IP "mailchimp_feed [...]" 4 +.IX Item "mailchimp_feed [...]" +A file with abused Mailchimp accounts. .SH "TEMPLATE TAGS" .IX Header "TEMPLATE TAGS" .RS 4 @@ -233,3 +239,5 @@ Tags that the plugin could set are: \&\s-1MAILUPID\s0 .IP "\(bu" 4 \&\s-1MAILDOMEID\s0 +.IP "\(bu" 4 +\&\s-1MAILCHIMPID\s0