libmail - simple POP3 mail checker library with
SSL support. libmail was specialy designed for utilities/widgets that
monitors for incoming of new mail from POP3 boxes.
interface
#include < libmail.h >
void mail_init(mail_t * mail, int secure, char * cert, char * server, int port);
The mail_init function initializes mail_t private structure with specified options, where secure indicates that SSL will be used, cert is PEM certificates file (can be NULL), server is mail box server address and port is mail box server port.
void mail_free(mail_t * mail);
mail_free function frees memory used by mail_t structure.
void mail_account(mail_t * mail, char * user, char * pass);
mail_account function set's up mail authorization information for user and it's password.
int mail_check(mail_t * mail); char* mail_error(int result);
mail_check function proceeds mail checking process for mail_t structure. On Success MAIL_EOK will be returned, otherwise error. Error description can be taken from mail_error function.
int mail_count(mail_t * mail); int mail_count_prev(mail_t * mail);
mail_count function returns current count of mails in box. mail_count_prev function returns count of mails in box from previous
example
int result; mail_t mail; mail_init(&mail, 1, "cert.pem", "pop3.mailserver.com", 110); mail_account(&mail, "user", "password"); result = mail_check(&mail); if ( result == MAIL_EOK ) printf("mail: %d\n", mail_count(&mail)); else printf("mail error: %s\n", mail_error(result)); mail_free(&mail);