![]() |
libwebsockets
Lightweight C library for HTML5 websockets
|
Data Structures | |
struct | lws_email |
Functions | |
LWS_VISIBLE LWS_EXTERN int | lws_email_init (struct lws_email *email, uv_loop_t *loop, int max_content) |
LWS_VISIBLE LWS_EXTERN void | lws_email_check (struct lws_email *email) |
LWS_VISIBLE LWS_EXTERN void | lws_email_destroy (struct lws_email *email) |
These apis let you communicate with a local SMTP server to send email from lws. It handles all the SMTP sequencing and protocol actions.
Your system should have postfix, sendmail or another MTA listening on port 25 and able to send email using the "mail" commandline app. Usually distro MTAs are configured for this by default.
It runs via its own libuv events if initialized (which requires giving it a libuv loop to attach to).
It operates using three callbacks, on_next() queries if there is a new email to send, on_get_body() asks for the body of the email, and on_sent() is called after the email is successfully sent.
To use it
When you have at least one email to send, call lws_email_check() to schedule starting to send it.
enum lwsgs_smtp_states |
#include <lib/libwebsockets.h>
enum lwsgs_smtp_states - where we are in SMTP protocol sequence
LWS_VISIBLE LWS_EXTERN void lws_email_check | ( | struct lws_email * | ) |
#include <lib/libwebsockets.h>
lws_email_check() - Request check for new email
struct lws_email context to check |
Schedules a check for new emails in 1s... call this when you have queued an email for send.
LWS_VISIBLE LWS_EXTERN void lws_email_destroy | ( | struct lws_email * | ) |
#include <lib/libwebsockets.h>
lws_email_destroy() - stop using the struct lws_email
the struct lws_email context |
Stop sending email using email and free allocations
LWS_VISIBLE LWS_EXTERN int lws_email_init | ( | struct lws_email * | email, |
uv_loop_t * | loop, | ||
int | max_content | ||
) |
#include <lib/libwebsockets.h>
lws_email_init() - Initialize a struct lws_email
struct lws_email to init | |
loop | libuv loop to use |
max_content | max email content size |
Prepares a struct lws_email for use ending SMTP