Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    SpamD: Add DNSWL's legitimate SMTP servers to whitelist

    Scheduled Pinned Locked Moved pfSense Packages
    2 Posts 2 Posters 2.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      comrax
      last edited by

      Hello all.

      I've written a small PHP script to fetch DNSWL's legitimate SMTP servers to SpamD's whitelist.
      There are few steps to make in order for this to work, so here we go:

      1. This has been tested on 1.2.1-RC3 (yes, it has been compiled tonight.)

      2. Connect to pfSense using SSH shell as we need to add a new package.

      3. Base pfSense don't include rsync command, so add it using: pkg_add -r rsync

      4. Make a new directory (/usr/local/dnswl) and make it current directory (chdir).

      5. Edit a new file (vi retrieve.php) and add the following code to it:

      #!/usr/local/bin/php -f
              $script_dir = dirname(__FILE__);
              $tmp_dir = md5(time());
              mkdir($script_dir.'/'.$tmp_dir);
              exec('/usr/local/bin/rsync --times "rsync1.dnswl.org::dnswl/generic-dnswl" "'.$script_dir.'/'.$tmp_dir.'/"');
              if(file_exists($dnswl_path = $script_dir.'/'.$tmp_dir.'/generic-dnswl')) {
                      $rptr = fopen($dnswl_path, 'r');
                      $optr = fopen($script_dir.'/generic-dnswl', 'wb');
                      if($rptr & $optr) {
                              while($line = fgets($rptr)) {
                                      $line = trim($line);
                                      if(!$line) {
                                              continue;
                                      }
                                      if('#' == $line{0}) {
                                              continue;
                                      }
                                      $semicolor_pos = strpos($line, ';');
                                      $line = substr($line, 0, $semicolor_pos);
                                      fputs($optr, $line."\n");
                              }
                      }
              }
      
              @exec('/bin/rm -rf "'.$script_dir.'/'.$tmp_dir.'"');
              @readfile($script_dir.'/generic-dnswl');
      
      ?>
      
      
      1. Go to (SpamD's External Sources) page, and click the [ + ] button to add a new entry.

      2. Fill in the following settings in the input values:

      • Provider Name: dnswl.org

      • Provider Type: whitelist

      • Provider Description: DNSWL.org provides a whitelist of known legitimate email servers to reduce the chances of false positives while spam filtering.

      • Reject message: Your own message goes here

      • Provider Method: Execute command

      • Provider URL or Filename: /usr/local/dnswl/retrieve.php

      Now, click the [ Save ] button to add the entry.

      SpamD is able now to retrieve the list of legitimate SMTP servers, and add it automatically.

      Enjoy!

      1 Reply Last reply Reply Quote 0
      • I
        iced98lx
        last edited by

        Comrax: doing excellent work here!! I'm updating to RC3 just so i can use this and the other patch you released to SPAMD!!

        Are you running greylisting or just white/black?

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.