Skip to content

Commit

Permalink
add support for TurboSmtp
Browse files Browse the repository at this point in the history
  • Loading branch information
bigio committed Dec 20, 2023
1 parent 6704ba8 commit 0dae34a
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Esp-rbl.cf
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,16 @@ ifplugin Mail::SpamAssassin::Plugin::Esp
tflags RBL_ESP_SPARKPOST net
endif

header ESP_TURBOSMTP eval:esp_turbosmtp_check()
describe ESP_TURBOSMTP Message from TurboSmtp abused account
score ESP_TURBOSMTP 0.01

ifplugin Mail::SpamAssassin::Plugin::AskDNS
askdns RBL_ESP_TURBOSMTP _TURBOSMTPID_.turbosmtp.espbl.snb.it A 127.0.0.1
describe RBL_ESP_TURBOSMTP Esp TurboSmtp blacklist
tflags RBL_ESP_TURBOSMTP net
endif

else

if (version >= 4.000000)
Expand Down Expand Up @@ -430,6 +440,13 @@ if (version >= 4.000000)
describe RBL_ESP_SPARKPOST Esp Sparkpost Id blacklist
tflags RBL_ESP_SPARKPOST net

header __ESP_TURBOSMTP_TR exists:X-TurboSMTP-Tracking
header __ESP_TURBOSMTP_ID Feedback-Id =~ /(?<TURBOSMTP_ID>.*)/
header __ESP_TURBOSMTP_RBL eval:check_hashbl_tag('turbosmtp.espbl.snb.it/A', 'raw', 'TURBOSMTP_ID', '^127\.')
meta RBL_ESP_TURBOSMTP ( __ESP_TURBOSMTP_TR && __ESP_TURBOSMTP_RBL )
describe RBL_ESP_TURBOSMTP Esp TurboSmtp Id blacklist
tflags RBL_ESP_TURBOSMTP net

endif
endif

Expand Down Expand Up @@ -460,3 +477,4 @@ score RBL_ESP_SENDGRID 4.0
score RBL_ESP_SENDINBLUE 4.0
score RBL_ESP_SMTPCOM 4.0
score RBL_ESP_SPARKPOST 4.0
score RBL_ESP_TURBOSMTP 4.0
7 changes: 7 additions & 0 deletions Esp.cf
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,11 @@ header SPARKPOST eval:esp_sparkpost_check()
describe SPARKPOST Message from Sparkpost abused account
score SPARKPOST 5.0

# -------- TURBOSMTP --------
turbosmtp_feed /etc/mail/spamassassin/turbosmtp_id.txt

header TURBOSMTP eval:esp_turbosmtp_check()
describe TURBOSMTP Message from TurboSmtp abused account
score TURBOSMTP 5.0

endif # Mail::SpamAssassin::Plugin::Esp
32 changes: 32 additions & 0 deletions Esp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ sub new {
$self->register_eval_rule('esp_sendinblue_check', $Mail::SpamAssassin::Conf::TYPE_HEAD_EVALS);
$self->register_eval_rule('esp_smtpcom_check', $Mail::SpamAssassin::Conf::TYPE_HEAD_EVALS);
$self->register_eval_rule('esp_sparkpost_check', $Mail::SpamAssassin::Conf::TYPE_HEAD_EVALS);
$self->register_eval_rule('esp_turbosmtp_check', $Mail::SpamAssassin::Conf::TYPE_HEAD_EVALS);

return $self;
}
Expand Down Expand Up @@ -181,6 +182,9 @@ Usage:
esp_sparkpost_check()
Checks for Sparkpost abused accounts
esp_turbosmtp_check()
Checks for TurboSmtp abused accounts
Every sub can be called with an options parameter which can contain the keywords "md5"
to crypt the Esp id using md5 algorithm and "nodash" which will substitute the "-" char
with a "_" in order to be possible to use the Esp id in dns records.
Expand Down Expand Up @@ -313,6 +317,11 @@ Files can be separated by a comma.
A list of files with abused Sparkpost accounts.
Files can be separated by a comma.
=item turbosmtp_feed [...]
A list of files with abused TurboSmtp accounts.
Files can be separated by a comma.
=back
=head1 TEMPLATE TAGS
Expand Down Expand Up @@ -404,6 +413,9 @@ SMTPCOMID
=item *
SPARKPOSTID
=item *
TURBOSMTPID
=back
=cut
Expand Down Expand Up @@ -562,6 +574,12 @@ sub set_config {
type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING,
}
);
push(@cmds, {
setting => 'turbosmtp_feed',
is_admin => 1,
type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING,
}
);
$conf->{parser}->register_commands(\@cmds);
}

Expand Down Expand Up @@ -592,6 +610,7 @@ sub finish_parsing_end {
$self->_read_configfile('sendinblue_feed', 'SENDINBLUE');
$self->_read_configfile('smtpcom_feed', 'SMTPCOM');
$self->_read_configfile('sparkpost_feed', 'SPARKPOST');
$self->_read_configfile('turbosmtp_feed', 'SPARKPOST');
}

sub _read_configfile {
Expand Down Expand Up @@ -1163,6 +1182,18 @@ sub esp_sparkpost_check {
return _hit_and_tag($self, $pms, $sparkpost_id, 'SPARKPOST', 'Sparkpost', 'SPARKPOSTID', $opts);
}

sub esp_turbosmtp_check {
my ($self, $pms, $opts) = @_;

my $tid = $pms->get("X-TurboSMTP-Tracking", undef);
return if not defined $tid;

my $fid = $pms->get("Feedback-Id", undef);
return if not defined $fid;

return _hit_and_tag($self, $pms, $fid, 'TURBOSMTP', 'TurboSmtp', 'TURBOSMTPID', $opts);
}

# Version features
sub has_esp_4dem_check { 1 };
sub has_esp_acelle_check { 1 };
Expand All @@ -1188,5 +1219,6 @@ sub has_esp_sendgrid_check { 1 };
sub has_esp_sendinblue_check { 1 };
sub has_esp_smtpcom_check { 1 };
sub has_esp_sparkpost_check { 1 };
sub has_esp_turbosmtp_check { 1 };

1;

0 comments on commit 0dae34a

Please sign in to comment.