process rcpt to addresses if they end .${hostid}

This commit is contained in:
SJ 2012-06-06 14:29:03 +02:00
parent 57adc425b8
commit f419106360
2 changed files with 40 additions and 1 deletions

View File

@ -195,6 +195,8 @@ void trimBuffer(char *s){
int extractEmail(char *rawmail, char *email){
char *p;
memset(email, 0, SMALLBUFSIZE);
p = strchr(rawmail, '<');
if(p){
snprintf(email, SMALLBUFSIZE-1, "%s", p+1);

View File

@ -18,7 +18,8 @@
struct _state parse_message(struct session_data *sdata, int take_into_pieces, struct __config *cfg){
FILE *f;
char buf[MAXBUFSIZE];
int i, len;
char *p, buf[MAXBUFSIZE], puf[SMALLBUFSIZE];
struct _state state;
init_state(&state);
@ -30,6 +31,42 @@ struct _state parse_message(struct session_data *sdata, int take_into_pieces, st
}
if(sdata->num_of_rcpt_to > 0){
for(i=0; i<sdata->num_of_rcpt_to; i++){
extractEmail(sdata->rcptto[i], puf);
if(strlen(puf) > 5){
p = strstr(puf, cfg->hostid);
if(p && *(p-1) == '.'){
*(p-1) = ' ';
*p = '\0';
len = strlen(puf);
if(does_it_seem_like_an_email_address(puf) == 1){
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: processing rcpt to address: *%s*", sdata->ttmpfile, puf);
if(strlen(state.b_to) < MAXBUFSIZE-len-1){
if(is_string_on_list(state.rcpt, puf) == 0){
append_list(&(state.rcpt), puf);
memcpy(&(state.b_to[strlen(state.b_to)]), puf, len);
if(strlen(state.b_to) < MAXBUFSIZE-len-1){
split_email_address(puf);
memcpy(&(state.b_to[strlen(state.b_to)]), puf, len);
}
}
}
}
}
}
}
}
if(take_into_pieces == 1){
state.mfd = open(sdata->tmpframe, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR);
if(state.mfd == -1){