spamdetect: Log all mail header lines
authorArjen Baart <arjen@andromeda.nl>
Fri, 25 Sep 2020 16:49:57 +0000 (18:49 +0200)
committerArjen Baart <arjen@andromeda.nl>
Fri, 25 Sep 2020 16:49:57 +0000 (18:49 +0200)
src/gcm_input/spamdetect.cpp

index cfe3367..38487fe 100644 (file)
@@ -57,6 +57,7 @@ int main(int argc, char *argv[])
    regex fwd_header("---- .+ Message -----");
    regex received("^Received:");
    regex from("^From:");
+   regex subject("^Subject:");
    regex returnpath("^Return-Path:");
 
    openlog("gnucomo", 0, LOG_MAIL);
@@ -64,6 +65,7 @@ int main(int argc, char *argv[])
 
    while (std::cin >> line)
    {
+      //std::cout <<   "[" << state << "]   checking " << line << "\n";  // DEBUG
       switch (state)
       {
       case 0:
@@ -75,7 +77,7 @@ int main(int argc, char *argv[])
 
       case 1:
          //  Inside the forwarded header
-         if (line == received || line == from || line == returnpath)
+         if (line == received || line == from || line == returnpath || line == subject)
          {
             header = line;
             state = 2;
@@ -84,14 +86,10 @@ int main(int argc, char *argv[])
       case 2:
          if (line == regex("^[^ ]+: "))
          {
+            //std::cout << "Header: " << header << "\n";   // DEBUG
             syslog(LOG_WARNING, "%s", (char *)header);
-            header = "";
-            state = 1;
-            if (line == received || line == from || line == returnpath)
-            {
-               header = line;
-               state = 2;
-            }
+
+            header = line;
          }
          else if (line == String(""))
          {