Hi all! To divide the log of mailsnarf in diferent files, i had to modify the source of mailsnarf.
But it's very easy! It's old code: static void print_mbox_msg(char *from, char *msg) { char *p; time_t t; t = time(NULL); if (from == NULL) from = "mailsnarf"; printf("From %s %s", from, ctime(&t)); while ((p = strsep(&msg, "\n")) != NULL) { if (strncmp(p, "From ", 5) == 0) putchar('>'); for (; *p != '\r' && *p != '\0'; p++) putchar(*p); putchar('\n'); } putchar('\n'); fflush(stdout); } And it's new code: static void print_mbox_msg(char *from, char *msg) { char *p; time_t t; FILE *fl; //ponteiro para o arquivo char *dir = "/home/edmafer/Maildir/new/"; char path[30]; t = time(NULL); //Pegando a data e hora de agora sprintf(path,"%s%d.%s",dir,cont++,"eml"); fl = fopen(path,"w"); if (!fl) { printf("\n<!>Erro ao tentar criar arquivo<!>\n"); //message the error on open the file. return; } if (from == NULL) //Definindo o from from = "mailsnarf"; fprintf(fl,"From %s %s", from, ctime(&t)); while ((p = strsep(&msg, "\n")) != NULL) { if (strncmp(p, "From ", 5) == 0) putc('>',fl); for (; *p != '\r' && *p != '\0'; p++) putc(*p,fl); putc('\n',fl); } putc('\n',fl); fflush(stdout); fclose(fl); //Fechando o arquivo } I redirect the messages in files. There are one variable named cont. This variable is an integer that return an number of files. On 4/10/06, Edson Marco Ferrari Junior <[EMAIL PROTECTED]> wrote:
Hi! I'm trying implements a more control on pop and smtp. With mailsnarf i get all e-mails, but i just save in one file, or print in screen. How i could to make to save each e-mail in different file? Or what other form to make it? Tank's -- /* * Edson Marco Ferrari Junior * [EMAIL PROTECTED] * http://www.itasoa.com.br (no dia que funcionar eu aviso) */
-- /* * Edson Marco Ferrari Junior * [EMAIL PROTECTED] * http://www.itasoa.com.br (no dia que funcionar eu aviso) */