pilerimport can remove message from imap server

This commit is contained in:
SJ 2013-11-26 16:04:54 +01:00
parent 1e44042b82
commit c02766a18c
4 changed files with 24 additions and 6 deletions

View File

@ -14,7 +14,7 @@
#define VERSION "0.1.25-master-branch" #define VERSION "0.1.25-master-branch"
#define BUILD 852 #define BUILD 853
#define HOSTID "mailarchiver" #define HOSTID "mailarchiver"

View File

@ -255,6 +255,7 @@ struct import {
int total_messages; int total_messages;
int processed_messages; int processed_messages;
int import_job_id; int import_job_id;
int remove_after_import;
time_t started, updated, finished; time_t started, updated, finished;
}; };

View File

@ -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); 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"); printf("\n");
return OK; return OK;

View File

@ -31,7 +31,6 @@ extern char *optarg;
extern int optind; extern int optind;
int dryrun=0; int dryrun=0;
int remove_after_successful_import = 0;
int import_from_gui=0; int import_from_gui=0;
@ -233,7 +232,7 @@ int import_from_maildir(char *directory, struct session_data *sdata, struct __da
ret = ERR; ret = ERR;
} }
if(remove_after_successful_import == 1 && ret != ERR) unlink(fname); if(data->import->remove_after_import == 1 && ret != ERR) unlink(fname);
i++; i++;
@ -481,7 +480,7 @@ int main(int argc, char **argv){
data.quiet = 0; data.quiet = 0;
import.import_job_id = import.total_messages = import.processed_messages = 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; data.import = &import;
@ -585,7 +584,7 @@ int main(int argc, char **argv){
break; break;
case 'r' : case 'r' :
remove_after_successful_import = 1; data.import->remove_after_import = 1;
break; break;
case 'G' : case 'G' :