Skip to content

Possibility of using remote SpamAssassin (spamd) instead of embedded one #42

@ramank775

Description

@ramank775

Thank you so much @mpaperno for your effort to create this amazing package!

I am exploring possibility to use SpamAssassin running on the remote server via spamd to be used along with the spampd.

To give more context, inspired by Mail-In-A-Box Architecture i have created a similar setup but docker based. Where spampd sits between the postfix and dovecot, analyse incoming mail for spam detection.

One of the problem i have faced using this architecture begin based on the docker, it loose the ability to train spam-assassin using sa-learn. While exploring for the solution i come across spamd. so i am currently exploring this possibility.

Based on the my understanding:

if we replace the Mail::SpamAssassin with Mail::SpamAssassin::Client and mades these following changes it should work

  • Change initialisation of assassin
- $sa_p = Mail::SpamAssassin->new($sa_p);
+ $sa_p = Mail::SpamAssassin::Client->new($sa_p);

-  $spd_p->{sa_awl} and eval {
-    require Mail::SpamAssassin::DBBasedAddrList;
-    # create a factory for the persistent address list
-    my $addrlistfactory = Mail::SpamAssassin::DBBasedAddrList->new();
-    $sa_p->set_persistent_address_list_factory($addrlistfactory);
-  };
-
-  $sa_p->compile_now(!!$sa_p->{userprefs_filename});
  • Instead of parsing the messages, pass it directly to check function
-    # Audit the message
-    if ($prop->{sa_version} >= 3) {
-      $mail = $assassin->parse(\@msglines, 0);
-      undef @msglines;  #clear some memory-- this screws up SA < v3
-    }
-    elsif ($prop->{sa_version} >= 2.70) {
-      $mail = Mail::SpamAssassin::MsgParser->parse(\@msglines);
-    }
-    else {
-      $mail = Mail::SpamAssassin::NoMailAudit->new(data => \@msglines);
-    }
-
-   # Check spamminess (returns Mail::SpamAssassin:PerMsgStatus object)
-    my $status = $assassin->check($mail);
+   my $status = $assassin->check(\@msglines);
  • Change the default assassin options of client instead of spamassassin. Or we can add a flag weather to start spampd with remote SpamAssassin or embedded.

Is these approach make sense to you? if so i would like to raise a PR so the same although being a someone who never uses perl i understand it may be time consuming for you to review it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions