diff --git a/src/config.h b/src/config.h index 65ea457e..071e30f9 100644 --- a/src/config.h +++ b/src/config.h @@ -14,7 +14,7 @@ #define VERSION "0.1.25-master-branch" -#define BUILD 852 +#define BUILD 853 #define HOSTID "mailarchiver" diff --git a/src/defs.h b/src/defs.h index 158d90c6..8d4e6aa7 100644 --- a/src/defs.h +++ b/src/defs.h @@ -255,6 +255,7 @@ struct import { int total_messages; int processed_messages; int import_job_id; + int remove_after_import; time_t started, updated, finished; }; diff --git a/src/imap.c b/src/imap.c index a954ab2d..04c03864 100644 --- a/src/imap.c +++ b/src/imap.c @@ -226,9 +226,27 @@ int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sda if(rc == ERR) printf("error importing '%s'\n", filename); - else unlink(filename); + else { + + if(data->import->remove_after_import == 1){ + snprintf(buf, sizeof(buf)-1, "A%d STORE %d +FLAGS.SILENT (\\Deleted)\r\n", *seq, i); + n = write1(sd, buf, strlen(buf), use_ssl, data->ssl); + read_response(sd, buf, sizeof(buf), seq, data, use_ssl); + } + + unlink(filename); + } + + } + if(data->import->remove_after_import == 1){ + snprintf(buf, sizeof(buf)-1, "A%d EXPUNGE\r\n", *seq); + n = write1(sd, buf, strlen(buf), use_ssl, data->ssl); + read_response(sd, buf, sizeof(buf), seq, data, use_ssl); + } + + printf("\n"); return OK; diff --git a/src/pilerimport.c b/src/pilerimport.c index 9eb27ff0..89dd578b 100644 --- a/src/pilerimport.c +++ b/src/pilerimport.c @@ -31,7 +31,6 @@ extern char *optarg; extern int optind; int dryrun=0; -int remove_after_successful_import = 0; int import_from_gui=0; @@ -233,7 +232,7 @@ int import_from_maildir(char *directory, struct session_data *sdata, struct __da ret = ERR; } - if(remove_after_successful_import == 1 && ret != ERR) unlink(fname); + if(data->import->remove_after_import == 1 && ret != ERR) unlink(fname); i++; @@ -481,7 +480,7 @@ int main(int argc, char **argv){ data.quiet = 0; import.import_job_id = import.total_messages = import.processed_messages = 0; - import.started = import.updated = import.finished = 0; + import.started = import.updated = import.finished = import.remove_after_import = 0; data.import = &import; @@ -585,7 +584,7 @@ int main(int argc, char **argv){ break; case 'r' : - remove_after_successful_import = 1; + data.import->remove_after_import = 1; break; case 'G' :