Пример #1
0
int main(int argc, char ** argv)
{
	struct mailimap * imap;
	int r;
	
	/*
	./imap-sample [email protected] mygmailpassword
	*/
	if (argc < 3) {
		fprintf(stderr, "usage: imap-sample [gmail-email-address] [password]\n");
		exit(EXIT_FAILURE);
	}
	
	mkdir("download", 0700);
	
	imap = mailimap_new(0, NULL);
	r = mailimap_ssl_connect(imap, "imap.gmail.com", 993);
	fprintf(stderr, "connect: %i\n", r);
	check_error(r, "could not connect to server");
	
	r = mailimap_login(imap, argv[1], argv[2]);
	check_error(r, "could not login");
	
	r = mailimap_select(imap, "INBOX");
	check_error(r, "could not select INBOX");
	
	fetch_messages(imap);
	
	mailimap_logout(imap);
	mailimap_free(imap);
	
	exit(EXIT_SUCCESS);
}
Пример #2
0
int main() {
	ii_base_init();
	
	struct list fetched=fetch_messages(adress, subscriptions);

	if (fetched.length>0) {
		char newmsg_filename[130];
		strcpy(newmsg_filename, indexdir);
		strcat(newmsg_filename, "newmsg");

		FILE* newmsg=fopen(newmsg_filename, "wb");
		int i;
		for (i=0; i<fetched.length; i++) {
			fputs(fetched.index[i], newmsg);
			fputs("\n", newmsg);
		}
		fclose(newmsg);
	}
}