Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tools:spamd [2022/07/10 21:51] darrontools:spamd [2022/07/12 13:25] (current) – external edit 127.0.0.1
Line 56: Line 56:
  
 <code> <code>
-:...skipping... 
 #! /usr/bin/perl #! /usr/bin/perl
 # #
 # By # By
-#       Darron M Broad 2022+#       Darron M Broad, July 2022
 # #
-# See:+# See
 #       https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Plugin.html #       https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Plugin.html
 #       https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Logger.html #       https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Logger.html
-#       https://spamassassin.apache.org/full/3.3.x/doc/Mail_SpamAssassin_PerMsgStatus.html+#       https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_PerMsgStatus.html
 # #
 # /etc/spamassassin/local.cf: # /etc/spamassassin/local.cf:
-# 
 #       loadplugin LocalPlugin /etc/spamassassin/local/plugin.pm #       loadplugin LocalPlugin /etc/spamassassin/local/plugin.pm
-# 
 #       header          LOCAL_FAKE_LIST eval:check_for_fake_list() #       header          LOCAL_FAKE_LIST eval:check_for_fake_list()
 #       score           LOCAL_FAKE_LIST 100 #       score           LOCAL_FAKE_LIST 100
Line 86: Line 83:
 { {
         my($class, $mailsa) = @_;         my($class, $mailsa) = @_;
- 
  
         $class = ref($class) || $class;         $class = ref($class) || $class;
Line 103: Line 99:
         my($self, $permsgstatus) = @_;         my($self, $permsgstatus) = @_;
  
-        $path = $permsgstatus->get("EnvelopeFrom");+        $from = $permsgstatus->get("EnvelopeFrom");
         my @to = split /@/, $permsgstatus->get("To:addr"); # x@y.z         my @to = split /@/, $permsgstatus->get("To:addr"); # x@y.z
         my $name = $to[0];         my $name = $to[0];
-        if ($name) { +        my $host = $to[1]; 
-                my $host = $to[1]; +        if ($from && $name && $host) { 
-                $s = "mail-$name=$host\@mail\."; +                # *mail-user=host@mail.* 
-                if ((rindex $path, $s, 0) == 0) { +                if ((index $from"mail-$name=$host\@mail\.") > 0) { 
-                        info("LocalPlugin: SPAM $path");+                        info("LocalPlugin: SPAM $from");
                         return 1;                         return 1;
                 }                 }
-                $s = "newsletter-$name=$host\@mail\."; +                newsletter-user=host@mail.* 
-                if ((rindex $path, $s, 0) == 0) { +                if ((rindex $from"newsletter-$name=$host\@mail\.", 0) == 0) { 
-                        info("LocalPlugin: SPAM $path");+                        info("LocalPlugin: SPAM $from");
                         return 1;                         return 1;
                 }                 }
         }         }
-    return 0;+        return 0;
 } }
  
 1; 1;
 +
 +# vim: shiftwidth=4 tabstop=4 noexpandtab
 </code> </code>
 +
 +===Spam===
 +
 +Here is a PHP command line tool to send test spam.
 +
 +Change Host,  Sender and addAddress as appropriate.
 +
 +<code>
 +#! /usr/bin/php -q
 +<?php
 +/* DEBIAN BUSTER */
 +require_once 'libphp-phpmailer/src/Exception.php';
 +require_once 'libphp-phpmailer/src/OAuth.php';
 +require_once 'libphp-phpmailer/src/PHPMailer.php';
 +require_once 'libphp-phpmailer/src/POP3.php';
 +require_once 'libphp-phpmailer/src/SMTP.php';
 +
 +use PHPMailer\PHPMailer\PHPMailer;
 +use PHPMailer\PHPMailer\SMTP;
 +use PHPMailer\PHPMailer\Exception;
 +
 +$mail = new PHPMailer(true);
 +
 +$mail->SMTPDebug = SMTP::DEBUG_SERVER;
 +$mail->isSMTP();
 +$mail->Host = 'localhost';
 +$mail->SMTPAuth = false;
 +
 +$mail->Sender = "newsletter-root=example.com@mail.example.com";
 +
 +$mail->setFrom('root@example.com', 'SPAM');
 +$mail->addAddress('root@example.com', "SPAM");
 +$mail->addReplyTo('root@example.com', 'SPAM');
 +
 +$mail->isHTML(false);
 +$mail->Subject = 'Subject';
 +$mail->Body = 'Body';
 +
 +try {
 +    $mail->send();
 +}
 +catch (Exception $e) {
 +    echo $e->getMessage();
 +}
 +/*
 + * vim: shiftwidth=4 tabstop=4 softtabstop=4 expandtab
 + */
 +?>
 +</code>
 +