DMARC support by opendmarc libs
[exim.git] / src / src / receive.c
index 4cea6d58ee038f19a11c35a2c01eea328d78df32..372747360df308259b51d2401b2376cc6ce79016 100644 (file)
 extern int dcc_ok;
 #endif
 
+#ifdef EXPERIMENTAL_DMARC
+#include "dmarc.h"
+#endif /* EXPERIMENTAL_DMARC */
+
 /*************************************************
 *                Local static variables          *
 *************************************************/
@@ -1480,6 +1484,10 @@ header_line *subject_header = NULL;
 header_line *msgid_header = NULL;
 header_line *received_header;
 
+#ifdef EXPERIMENTAL_DMARC
+int dmarc_up = 0;
+#endif /* EXPERIMENTAL_DMARC */
+
 /* Variables for use when building the Received: header. */
 
 uschar *timestamp;
@@ -1536,6 +1544,11 @@ message_linecount = body_linecount = body_zerocount =
 if (smtp_input && !smtp_batched_input && !dkim_disable_verify) dkim_exim_verify_init();
 #endif
 
+#ifdef EXPERIMENTAL_DMARC
+/* initialize libopendmarc */
+dmarc_up = dmarc_init();
+#endif
+
 /* Remember the time of reception. Exim uses time+pid for uniqueness of message
 ids, and fractions of a second are required. See the comments that precede the
 message id creation below. */
@@ -2706,7 +2719,6 @@ if (from_header != NULL &&
     }
   }
 
-
 /* If there are any rewriting rules, apply them to the sender address, unless
 it has already been rewritten as part of verification for SMTP input. */
 
@@ -3238,7 +3250,6 @@ else
           }
         }
       }
-#endif /* DISABLE_DKIM */
 
 #ifdef WITH_CONTENT_SCAN
     if (recipients_count > 0 &&
@@ -3247,6 +3258,10 @@ else
       goto TIDYUP;
 #endif /* WITH_CONTENT_SCAN */
 
+#ifdef EXPERIMENTAL_DMARC
+    dmarc_up = dmarc_store_data(from_header);
+#endif /* EXPERIMENTAL_DMARC */
+
 #ifdef EXPERIMENTAL_PRDR
     if (prdr_requested && recipients_count > 1 && acl_smtp_data_prdr != NULL )
       {
@@ -3411,6 +3426,8 @@ else
       }
     }
 
+#endif /* DISABLE_DKIM */
+
   /* The applicable ACLs have been run */
 
   if (deliver_freeze) frozen_by = US"ACL";     /* for later logging */