4 * Reject incoming SMTP messages containing strings that tell us that the
5 * message is probably spam.
18 #include <sys/types.h>
20 #if TIME_WITH_SYS_TIME
21 # include <sys/time.h>
25 # include <sys/time.h>
36 #include "sysdep_decls.h"
37 #include "citserver.h"
41 #include "dynloader.h"
48 #include "internet_addressing.h"
51 /* Scan a message for spam */
52 int spam_filter(struct CtdlMessage *msg) {
53 int spam_strings_found = 0;
54 struct spamstrings_t *sptr;
57 /* Bail out if there's no message text */
58 if (msg->cm_fields['M'] == NULL) return(0);
62 ptr = msg->cm_fields['M'];
63 while (ptr++[0] != 0) {
64 for (sptr = spamstrings; sptr != NULL; sptr = sptr->next) {
65 if (!strncasecmp(ptr, sptr->string,
66 strlen(sptr->string))) {
72 if (spam_strings_found) {
73 if (msg->cm_fields['0'] != NULL) {
74 phree(msg->cm_fields['0']);
76 msg->cm_fields['0'] = strdoop("Unsolicited spam rejected");
77 return(spam_strings_found);
85 char *Dynamic_Module_Init(void)
87 CtdlRegisterMessageHook(spam_filter, EVT_SMTPSCAN);