This is simple SMTP client for raw API. It is a minimal implementation of SMTP as specified in RFC 5321.
Example usage:
{
printf(
"mail (%p) sent with results: 0x%02x, 0x%04x, 0x%08x\n",
arg,
smtp_result, srv_err,
err);
}
static void my_smtp_test(void)
{
smtp_send_mail(
"sender",
"recipient",
"subject",
"body", my_smtp_result_fn,
some_argument);
}
static WCHAR no[MAX_STRING_RESOURCE_LEN]
err_t smtp_set_server_addr(const char *server)
err_t smtp_set_auth(const char *username, const char *pass)
err_t smtp_send_mail(const char *from, const char *to, const char *subject, const char *body, smtp_result_fn callback_fn, void *callback_arg)
When using from any other thread than the tcpip_thread (for NO_SYS==0), use smtp_send_mail_int()!
SMTP_BODYDH usage:
int my_smtp_bodydh_fn(
void *
arg,
struct smtp_bodydh *bdh)
{
if(bdh->state >= 10) {
return BDH_DONE;
}
sprintf(bdh->buffer,
"Line #%2d\r\n",bdh->state);
bdh->length =
strlen(bdh->buffer);
++bdh->state;
return BDH_WORKING;
}
smtp_send_mail_bodycback("sender", "recipient", "subject",
my_smtp_bodydh_fn, my_smtp_result_fn, some_argument);
ACPI_SIZE strlen(const char *String)
#define sprintf(buf, format,...)
- Todo:
- :
- attachments (the main difficulty here is streaming base64-encoding to prevent having to allocate a buffer for the whole encoded file at once)
- test with more mail servers...