subrelay/include/ilib/curl_imapsmtp.h

57 lines
2.0 KiB
C
Raw Normal View History

2026-10-15 02:26:58 +03:00
/*
* this is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* this is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.";
*
* (c) Alexander Vdolainen 2007, 2026 <alex@vapaa.xyz>
* subrelay: a minimalistic maillist server based on external IMAPs/SMTPs
*
* curl_imapsmtp.h: IMAPS SMTPs functions using libcurl
*
*/
#ifndef __MAIL_ENGINE_H__
#define __MAIL_ENGINE_H__
#include <stddef.h>
#include <ilib/configuration.h>
#define MAX_IMAP_RESPONSE (25u * 1024u * 1024u)
typedef struct mail_message {
char *raw_data; /* Full raw RFC 822 byte payload */
size_t size; /* Size of raw payload */
unsigned long uid; /* IMAP Unique Identifier */
} mail_message_t;
typedef struct mail_list_results {
unsigned long *uids;
size_t count;
} mail_list_results_t;
/* Initialize and cleanup global libcurl environment */
int mail_engine_global_init(void);
void mail_engine_global_cleanup(void);
/* IMAP Client API */
int imap_fetch_unseen_uids(const subrelay_config_t *cfg, mail_list_results_t *results);
int imap_fetch_message(const subrelay_config_t *cfg, unsigned long uid, mail_message_t *msg);
int imap_expunge_message(const subrelay_config_t *cfg, unsigned long uid);
void mail_message_free(mail_message_t *msg);
void mail_list_results_free(mail_list_results_t *res);
/* SMTP Client API */
int smtp_send_message(const subrelay_config_t *cfg, const char **recipients,
size_t recipient_count, const char *raw_msg, size_t msg_len);
#endif /* __MAIL_ENGINE_H__ */