libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-smtp.h
Go to the documentation of this file.
1/*
2 * libwebsockets - small server side websockets and web server implementation
3 *
4 * Copyright (C) 2010 - 2026 Andy Green <andy@warmcat.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25#ifndef _LWS_SMTP_H
26#define _LWS_SMTP_H
27
50
51/* the limits lws_smtp_email_check() applies */
52#define LWS_SMTP_ADDR_MAX 254 /* an address, without the <> */
53#define LWS_SMTP_LOCAL_MAX 64 /* the part before the @ */
54#define LWS_SMTP_SUBJECT_MAX 512 /* bytes of UTF-8 */
55#define LWS_SMTP_MSGID_MAX 128 /* without the <> */
56#define LWS_SMTP_LINE_MAX 998 /* a body line as sent, RFC 5322 2.1.1 */
57
58/* the smallest buffer lws_smtp_session_tx() can always make progress in */
59#define LWS_SMTP_TX_MIN 512
60
61typedef struct lws_smtp_email {
62 const char *from;
64 const char *to;
66 const char *subject;
68 const char *body;
70 const char *message_id;
73 int64_t date;
77
103
109typedef struct lws_smtp_session {
110 const lws_smtp_email_t *mail; /* the mail in progress, or NULL */
111 const char *helo; /* our name for EHLO and HELO */
112
113 size_t pos; /* position in the tx item */
114 int code; /* the last complete reply's code */
115 char text[96]; /* its last line's text */
116
124 char rx_kw[16];
125
127 uint8_t item; /* what of the message tx is at */
130
148
157lws_smtp_addr_check(const char *addr);
158
172lws_smtp_session_init(lws_smtp_session_t *s, const char *helo, int starttls);
173
190 size_t *used);
191
206 size_t *produced);
207
218
234
236
237#endif /* _LWS_SMTP_H */
char text[96]
Definition lws-smtp.h:115
uint8_t rx_kw_len
Definition lws-smtp.h:122
uint8_t rx_text_len
Definition lws-smtp.h:121
uint16_t rx_first_code
Definition lws-smtp.h:119
uint8_t rx_kw_end
Definition lws-smtp.h:123
const char * subject
Definition lws-smtp.h:66
uint16_t rx_line_len
Definition lws-smtp.h:117
const char * helo
Definition lws-smtp.h:111
uint8_t rx_state
Definition lws-smtp.h:120
const char * message_id
Definition lws-smtp.h:70
const char * to
Definition lws-smtp.h:64
char rx_kw[16]
Definition lws-smtp.h:124
const lws_smtp_email_t * mail
Definition lws-smtp.h:110
int64_t date
Definition lws-smtp.h:73
uint16_t rx_code
Definition lws-smtp.h:118
const char * from
Definition lws-smtp.h:62
const char * body
Definition lws-smtp.h:68
struct lws_smtp_email lws_smtp_email_t
LWS_VISIBLE LWS_EXTERN int lws_smtp_session_mail(lws_smtp_session_t *s, const lws_smtp_email_t *mail)
LWS_VISIBLE LWS_EXTERN int lws_smtp_email_check(const lws_smtp_email_t *e)
LWS_VISIBLE LWS_EXTERN lws_smtp_ev_t lws_smtp_session_rx(lws_smtp_session_t *s, const uint8_t *buf, size_t len, size_t *used)
enum lws_smtp_ev lws_smtp_ev_t
LWS_VISIBLE LWS_EXTERN void lws_smtp_session_tls_up(lws_smtp_session_t *s)
LWS_VISIBLE LWS_EXTERN int lws_smtp_addr_check(const char *addr)
lws_smtp_ev
Definition lws-smtp.h:79
LWS_VISIBLE LWS_EXTERN void lws_smtp_session_init(lws_smtp_session_t *s, const char *helo, int starttls)
struct lws_smtp_session lws_smtp_session_t
LWS_VISIBLE LWS_EXTERN int lws_smtp_session_tx(lws_smtp_session_t *s, uint8_t *buf, size_t max, size_t *produced)
@ LWS_SMTP_EV_TX
Definition lws-smtp.h:82
@ LWS_SMTP_EV_READY
Definition lws-smtp.h:89
@ LWS_SMTP_EV_STARTTLS
Definition lws-smtp.h:85
@ LWS_SMTP_EV_NONE
Definition lws-smtp.h:80
@ LWS_SMTP_EV_MAIL_DONE
Definition lws-smtp.h:92
@ LWS_SMTP_EV_CLOSE
Definition lws-smtp.h:96
@ LWS_SMTP_EV_FAILED
Definition lws-smtp.h:98
unsigned short uint16_t
#define LWS_EXTERN
unsigned char uint8_t
#define LWS_VISIBLE