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);
}
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);