ReactOS 0.4.16-dev-334-g4d9f67c
SMTP client
Collaboration diagram for SMTP client:

Modules

 Options
 

Detailed Description

This is simple SMTP client for raw API. It is a minimal implementation of SMTP as specified in RFC 5321.

Example usage:

void my_smtp_result_fn(void *arg, u8_t smtp_result, u16_t srv_err, err_t err)
{
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_set_server_addr("mymailserver.org");
-> set both username and password as NULL if no auth needed
smtp_set_auth("username", "password");
smtp_send_mail("sender", "recipient", "subject", "body", my_smtp_result_fn,
some_argument);
}
Definition: _set.h:50
#define NULL
Definition: types.h:112
static WCHAR no[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2340
#define printf
Definition: freeldr.h:97
uint8_t u8_t
Definition: arch.h:125
uint16_t u16_t
Definition: arch.h:127
s8_t err_t
Definition: err.h:96
static WCHAR password[]
Definition: url.c:33
static WCHAR username[]
Definition: url.c:32
#define err(...)
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)
Definition: utclib.c:269
#define sprintf(buf, format,...)
Definition: sprintf.c:55
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...