From 39a2e6a306b70112fc72b54696c149eb5ae871ae Mon Sep 17 00:00:00 2001 From: SJ Date: Mon, 30 Jun 2014 16:10:36 +0200 Subject: [PATCH] support for VERP addresses --- src/config.h | 2 +- src/misc.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/config.h b/src/config.h index 670d4b71..6a71769a 100644 --- a/src/config.h +++ b/src/config.h @@ -14,7 +14,7 @@ #define VERSION "0.1.25-rc3" -#define BUILD 876 +#define BUILD 877 #define HOSTID "mailarchiver" diff --git a/src/misc.c b/src/misc.c index 7050b750..e2e1f93d 100644 --- a/src/misc.c +++ b/src/misc.c @@ -193,12 +193,29 @@ int trimBuffer(char *s){ int extractEmail(char *rawmail, char *email){ - char *p; + char *p, *q1, *q2; memset(email, 0, SMALLBUFSIZE); + // extract both regular and VERP addresses, eg. + // aaa@aaa.fu and archive+user=domain.com@myarchive.local + p = strchr(rawmail, '<'); if(p){ + q1 = strchr(p+1, '+'); + if(q1){ + q2 = strchr(q1+1, '='); + if(q2){ + p = strchr(q2, '@'); + if(p){ + *p = '\0'; + *q2 = '@'; + snprintf(email, SMALLBUFSIZE-1, "%s", q1+1); + return 1; + } + } + } + snprintf(email, SMALLBUFSIZE-1, "%s", p+1); p = strchr(email, '>'); if(p){