1

I've been reading on SpamAssassin for some time now and learned a lot but I cannot seem to figure out a way I cannot find a way to create a rule where a 3rd party script can be executed to for a custom rule. THis would have to be something user based not globally.

I want to run additional verifications on domains and email addresses.

I wish to build a reputation system in which if a domain or email address are checked against the contacts list and other things.

I have have considered modifying the profile to add regex rules but that seems like a way to complicated way of doing it. A more preferred scenario would be to simply run a 3rd party script that returns the score for each domain and email address.

transilvlad
  • 13,974
  • 13
  • 45
  • 80

2 Answers2

1

Out of the box, SpamAssassin has no such facility, but since you ask on a programming site, I assume you are not alien to writing some code on your own.

The plugin facility in SpamAssassin was designed for this sort of thing. You can create a piece of Perl code which gets called for each message which SpamAssassin analyzes, and you have access to everything Perl has access to.

In particular, look at the pyzor plugin which calls an external program and returns its analysis results to SpamAssassin. There's a fair amount of boilerplate there, but the part you need to start with is getting the right arguments to the helper_app_pipe_open call (on line 282 as of version 3.4.0, which is what I link to above). These things are configurable so you could perhaps even just reconfigure the path to pyzor to your own program as a proof of concept. Note that it needs to accept a check argument and some other parameters, and a message from a temporary file on its standard input.

Mail::SpamAssassin::Plugin.pm contains POD documentation for the plugin API. Other files in the module tree contain useful documentation too; in particular, you might want to refer to the general documentation in Mail::SpamAssassin.pm and Mail::SpamAssassin::Conf.pm to understand the configuration parameters you can pass to your plugin.

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • What about adding a rule with a call to exec something? I am trying to get this done as a user config thing in order to not require any change done to SA. – transilvlad Oct 01 '14 at 13:31
  • Then why do you post to a programming site? But anyway, I'll repeat the idea to use the `pyzor` plugin but make it call your own checking tool instead. You'll probably need some wrapping to make it behave like the `pyzor` plugin expects, but it should not be too hard. – tripleee Oct 01 '14 at 13:34
0

Out of the box, there is a new TxRep plugin that automatically recognizes senders you've seen recently. There is also a collection of whitelist and blacklist options.

If you wanted to implement something yourself, I think you'll quickly find that an exec mechanism won't scale well. Perhaps try crafting your own DNSBL instead. This can be done with custom code and any DNS server (e.g. bind, dnsmasq, etc) or with a DNS server designed for this purpose, such as RBLDNSD. The SA wiki on DnsBlocklists has directions for how to hook it into SA.

Usually, people seeking this kind of solution don't have DNSBLs configured properly. I'd take a look into that before trying to build your own project.

Adam Katz
  • 14,455
  • 5
  • 68
  • 83