Example Plugin

The purpose of the following code snipped is to demonstrate how you can work with the spmfilter-API within spmfilter-plugins. This (quite dumb) spmfilter-plugin just logs the envelope-sender and envelope-recipients:

 1 #include <stdlib.h>
 2 #include <stdio.h>
 3 #include <spmfilter.h>
 4 #define THIS_MODULE "test" 
 5 
 6 /* start here */
 7 int load([[SMFSession_T]] *session) {
 8 
 9      int i;
10 
11     /* first log the envelope sender */
12     TRACE(TRACE_INFO, "envelope sender: %s", session->envelope_from->addr);
13 
14      /* go through all recipient adresses, count of recipients is found in session->envelope_to_num  */
15      for(i=0; i < session->envelope_to_num; i++) {
16 
17            /* log address to Logfile */
18            TRACE(TRACE_INFO, "recipient found: %s",session->envelope_to[i]->addr);
19      }
20 return 0;
21 }
Powered by SpaceNet