diff --git a/etc/example.conf b/etc/example.conf index 8cce756..8d7e554 100644 --- a/etc/example.conf +++ b/etc/example.conf @@ -52,6 +52,12 @@ piler_header_field=X-piler: piler already archived this email +; whether to archive an email not having a Message-ID header line (1) +; or not (0). +; If enabled then piler will assign piler_id as the message-id +archive_emails_not_having_message_id=0 + + ; comma separated list of your domains. piler uses this information to determine ; the direction of the given email diff --git a/src/cfg.c b/src/cfg.c index 41ae0c0..92ca197 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -59,6 +59,7 @@ struct _parse_rule config_parse_rules[] = { + { "archive_emails_not_having_message_id", "integer", (void*) int_parser, offsetof(struct __config, archive_emails_not_having_message_id), "0", sizeof(int)}, { "backlog", "integer", (void*) int_parser, offsetof(struct __config, backlog), "20", sizeof(int)}, { "clamd_addr", "string", (void*) string_parser, offsetof(struct __config, clamd_addr), "", MAXVAL-1}, { "clamd_port", "integer", (void*) int_parser, offsetof(struct __config, clamd_port), "0", sizeof(int)}, diff --git a/src/cfg.h b/src/cfg.h index 6c688ce..93fc501 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -62,6 +62,7 @@ int update_counters_to_memcached; int memcached_to_db_interval; + int archive_emails_not_having_message_id; }; diff --git a/src/parser.c b/src/parser.c index e99c5f1..8ef39e3 100644 --- a/src/parser.c +++ b/src/parser.c @@ -123,7 +123,11 @@ } - if(state->message_id[0] == 0) snprintf(state->message_id, SMALLBUFSIZE-1, "null"); + if(state->message_id[0] == 0){ + if(cfg->archive_emails_not_having_message_id == 1) + snprintf(state->message_id, SMALLBUFSIZE-1, sdata->ttmpfile); + else snprintf(state->message_id, SMALLBUFSIZE-1, "null"); + } len = strlen(state->b_from); if(state->b_from[len-1] == ' ') state->b_from[len-1] = '\0'; @@ -131,7 +135,6 @@ len = strlen(state->b_to); if(state->b_to[len-1] == ' ') state->b_to[len-1] = '\0'; - //syslog(LOG_PRIORITY, "%s: from=%s, to=%s, subj=%s, message-id=%s, reference=%s", sdata->ttmpfile, state->b_from, state->b_to, state->b_subject, state->message_id, state->reference); }