TuyaOS
smtp.h
1#ifndef LWIP_HDR_APPS_SMTP_H
2#define LWIP_HDR_APPS_SMTP_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include "lwip/apps/smtp_opts.h"
9#include "lwip/err.h"
10#include "lwip/prot/iana.h"
11
13#define SMTP_DEFAULT_PORT LWIP_IANA_PORT_SMTP
15#define SMTPS_DEFAULT_PORT LWIP_IANA_PORT_SMTPS
16
18#define SMTP_RESULT_OK 0
20#define SMTP_RESULT_ERR_UNKNOWN 1
22#define SMTP_RESULT_ERR_CONNECT 2
24#define SMTP_RESULT_ERR_HOSTNAME 3
26#define SMTP_RESULT_ERR_CLOSED 4
28#define SMTP_RESULT_ERR_TIMEOUT 5
30#define SMTP_RESULT_ERR_SVR_RESP 6
32#define SMTP_RESULT_ERR_MEM 7
33
42typedef void (*smtp_result_fn)(void *arg, u8_t smtp_result, u16_t srv_err, err_t err);
43
55 const char *from;
56 const char* to;
57 const char* subject;
58 const char* body;
59 smtp_result_fn callback_fn;
60 void* callback_arg;
66};
67
68
69#if SMTP_BODYDH
70
71#ifndef SMTP_BODYDH_BUFFER_SIZE
72#define SMTP_BODYDH_BUFFER_SIZE 256
73#endif /* SMTP_BODYDH_BUFFER_SIZE */
74
75struct smtp_bodydh {
76 u16_t state;
77 u16_t length; /* Length of content in buffer */
78 char buffer[SMTP_BODYDH_BUFFER_SIZE]; /* buffer for generated content */
79#ifdef SMTP_BODYDH_USER_SIZE
80 u8_t user[SMTP_BODYDH_USER_SIZE];
81#endif /* SMTP_BODYDH_USER_SIZE */
82};
83
84enum bdh_retvals_e {
85 BDH_DONE = 0,
86 BDH_WORKING
87};
88
100typedef int (*smtp_bodycback_fn)(void *arg, struct smtp_bodydh *bodydh);
101
102err_t smtp_send_mail_bodycback(const char *from, const char* to, const char* subject,
103 smtp_bodycback_fn bodycback_fn, smtp_result_fn callback_fn, void* callback_arg);
104
105#endif /* SMTP_BODYDH */
106
107
108err_t smtp_set_server_addr(const char* server);
109void smtp_set_server_port(u16_t port);
110#if LWIP_ALTCP && LWIP_ALTCP_TLS
111struct altcp_tls_config;
112void smtp_set_tls_config(struct altcp_tls_config *tls_config);
113#endif
114err_t smtp_set_auth(const char* username, const char* pass);
115err_t smtp_send_mail(const char *from, const char* to, const char* subject, const char* body,
116 smtp_result_fn callback_fn, void* callback_arg);
117err_t smtp_send_mail_static(const char *from, const char* to, const char* subject, const char* body,
118 smtp_result_fn callback_fn, void* callback_arg);
119void smtp_send_mail_int(void *arg);
120#ifdef LWIP_DEBUG
121const char* smtp_result_str(u8_t smtp_result);
122#endif
123
124#ifdef __cplusplus
125}
126#endif
127
128#endif /* LWIP_HDR_APPS_SMTP_H */
s8_t err_t
Definition: err.h:96
Definition: smtp.h:54
u8_t static_data
Definition: smtp.h:65