\hypertarget{group__smtp}{}\section{Smtp} \label{group__smtp}\index{Smtp@{Smtp}} \subsection*{Data Structures} \begin{DoxyCompactItemize} \item struct \hyperlink{structlws__email}{lws\+\_\+email} \end{DoxyCompactItemize} \subsection*{Enumerations} \begin{DoxyCompactItemize} \item enum \hyperlink{group__smtp_ga116be79bf44f9dc2a97f46e051fe4dc0}{lwsgs\+\_\+smtp\+\_\+states} \{ \\* \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a29e5b0ecf75375b5a643faa3d6222b7c}{L\+G\+S\+S\+M\+T\+P\+\_\+\+I\+D\+LE}, \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0ab89442b7a3ca2b94c3cdcf33756eb933}{L\+G\+S\+S\+M\+T\+P\+\_\+\+C\+O\+N\+N\+E\+C\+T\+I\+NG}, \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0ab61778f70ecac007b334bb14942eb41d}{L\+G\+S\+S\+M\+T\+P\+\_\+\+C\+O\+N\+N\+E\+C\+T\+ED}, \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a1dfec948a864205cec875f63cbe0d4ad}{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+H\+E\+LO}, \\* \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a929bb4623ff3f585108aba2a1b047fab}{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+F\+R\+OM}, \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0aae20a0cb95b97a70f6b45d0ed2d5be83}{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+TO}, \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a85e3c452950c09a79086bff4b9be5c14}{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+D\+A\+TA}, \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a38fba41f28d754e38079b31418a86a69}{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+B\+O\+DY}, \\* \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a2c2ed16ffc572326e3040684084b21d5}{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+Q\+U\+IT} \} \end{DoxyCompactItemize} \subsection*{Functions} \begin{DoxyCompactItemize} \item L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN int \hyperlink{group__smtp_ga77fc9b56a1bb39484844981ec375fc29}{lws\+\_\+email\+\_\+init} (struct \hyperlink{structlws__email}{lws\+\_\+email} $\ast$email, uv\+\_\+loop\+\_\+t $\ast$loop, int max\+\_\+content) \item L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN void \hyperlink{group__smtp_ga5e535e346d92a9daf00be33abf79d4eb}{lws\+\_\+email\+\_\+check} (struct \hyperlink{structlws__email}{lws\+\_\+email} $\ast$email) \item L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN void \hyperlink{group__smtp_ga25298a5afc1074e13b2d5711a86432b2}{lws\+\_\+email\+\_\+destroy} (struct \hyperlink{structlws__email}{lws\+\_\+email} $\ast$email) \end{DoxyCompactItemize} \subsection{Detailed Description} \subsubsection*{S\+M\+TP related functions} These apis let you communicate with a local S\+M\+TP server to send email from lws. It handles all the S\+M\+TP sequencing and protocol actions. Your system should have postfix, sendmail or another M\+TA listening on port 25 and able to send email using the \char`\"{}mail\char`\"{} commandline app. Usually distro M\+T\+As 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 \begin{DoxyItemize} \item create an \hyperlink{structlws__email}{lws\+\_\+email} struct \item initialize data, loop, the email\+\_\+$\ast$ strings, max\+\_\+content\+\_\+size and the callbacks \item call \hyperlink{group__smtp_ga77fc9b56a1bb39484844981ec375fc29}{lws\+\_\+email\+\_\+init()} \end{DoxyItemize} When you have at least one email to send, call \hyperlink{group__smtp_ga5e535e346d92a9daf00be33abf79d4eb}{lws\+\_\+email\+\_\+check()} to schedule starting to send it. \subsection{Enumeration Type Documentation} \index{Smtp@{Smtp}!lwsgs\+\_\+smtp\+\_\+states@{lwsgs\+\_\+smtp\+\_\+states}} \index{lwsgs\+\_\+smtp\+\_\+states@{lwsgs\+\_\+smtp\+\_\+states}!Smtp@{Smtp}} \subsubsection[{\texorpdfstring{lwsgs\+\_\+smtp\+\_\+states}{lwsgs\_smtp\_states}}]{\setlength{\rightskip}{0pt plus 5cm}enum {\bf lwsgs\+\_\+smtp\+\_\+states}}\hypertarget{group__smtp_ga116be79bf44f9dc2a97f46e051fe4dc0}{}\label{group__smtp_ga116be79bf44f9dc2a97f46e051fe4dc0} {\ttfamily \#include $<$\hyperlink{libwebsockets_8h}{lib/libwebsockets.\+h}$>$} enum lwsgs\+\_\+smtp\+\_\+states -\/ where we are in S\+M\+TP protocol sequence \begin{Desc} \item[Enumerator]\par \begin{description} \index{L\+G\+S\+S\+M\+T\+P\+\_\+\+I\+D\+LE@{L\+G\+S\+S\+M\+T\+P\+\_\+\+I\+D\+LE}!Smtp@{Smtp}}\index{Smtp@{Smtp}!L\+G\+S\+S\+M\+T\+P\+\_\+\+I\+D\+LE@{L\+G\+S\+S\+M\+T\+P\+\_\+\+I\+D\+LE}}\item[{\em L\+G\+S\+S\+M\+T\+P\+\_\+\+I\+D\+LE\hypertarget{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a29e5b0ecf75375b5a643faa3d6222b7c}{}\label{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a29e5b0ecf75375b5a643faa3d6222b7c} }]awaiting new email \index{L\+G\+S\+S\+M\+T\+P\+\_\+\+C\+O\+N\+N\+E\+C\+T\+I\+NG@{L\+G\+S\+S\+M\+T\+P\+\_\+\+C\+O\+N\+N\+E\+C\+T\+I\+NG}!Smtp@{Smtp}}\index{Smtp@{Smtp}!L\+G\+S\+S\+M\+T\+P\+\_\+\+C\+O\+N\+N\+E\+C\+T\+I\+NG@{L\+G\+S\+S\+M\+T\+P\+\_\+\+C\+O\+N\+N\+E\+C\+T\+I\+NG}}\item[{\em L\+G\+S\+S\+M\+T\+P\+\_\+\+C\+O\+N\+N\+E\+C\+T\+I\+NG\hypertarget{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0ab89442b7a3ca2b94c3cdcf33756eb933}{}\label{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0ab89442b7a3ca2b94c3cdcf33756eb933} }]opening tcp connection to M\+TA \index{L\+G\+S\+S\+M\+T\+P\+\_\+\+C\+O\+N\+N\+E\+C\+T\+ED@{L\+G\+S\+S\+M\+T\+P\+\_\+\+C\+O\+N\+N\+E\+C\+T\+ED}!Smtp@{Smtp}}\index{Smtp@{Smtp}!L\+G\+S\+S\+M\+T\+P\+\_\+\+C\+O\+N\+N\+E\+C\+T\+ED@{L\+G\+S\+S\+M\+T\+P\+\_\+\+C\+O\+N\+N\+E\+C\+T\+ED}}\item[{\em L\+G\+S\+S\+M\+T\+P\+\_\+\+C\+O\+N\+N\+E\+C\+T\+ED\hypertarget{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0ab61778f70ecac007b334bb14942eb41d}{}\label{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0ab61778f70ecac007b334bb14942eb41d} }]tcp connection to M\+TA is connected \index{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+H\+E\+LO@{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+H\+E\+LO}!Smtp@{Smtp}}\index{Smtp@{Smtp}!L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+H\+E\+LO@{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+H\+E\+LO}}\item[{\em L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+H\+E\+LO\hypertarget{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a1dfec948a864205cec875f63cbe0d4ad}{}\label{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a1dfec948a864205cec875f63cbe0d4ad} }]sent the H\+E\+LO \index{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+F\+R\+OM@{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+F\+R\+OM}!Smtp@{Smtp}}\index{Smtp@{Smtp}!L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+F\+R\+OM@{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+F\+R\+OM}}\item[{\em L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+F\+R\+OM\hypertarget{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a929bb4623ff3f585108aba2a1b047fab}{}\label{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a929bb4623ff3f585108aba2a1b047fab} }]sent F\+R\+OM \index{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+TO@{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+TO}!Smtp@{Smtp}}\index{Smtp@{Smtp}!L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+TO@{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+TO}}\item[{\em L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+TO\hypertarget{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0aae20a0cb95b97a70f6b45d0ed2d5be83}{}\label{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0aae20a0cb95b97a70f6b45d0ed2d5be83} }]sent TO \index{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+D\+A\+TA@{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+D\+A\+TA}!Smtp@{Smtp}}\index{Smtp@{Smtp}!L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+D\+A\+TA@{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+D\+A\+TA}}\item[{\em L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+D\+A\+TA\hypertarget{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a85e3c452950c09a79086bff4b9be5c14}{}\label{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a85e3c452950c09a79086bff4b9be5c14} }]sent D\+A\+TA request \index{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+B\+O\+DY@{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+B\+O\+DY}!Smtp@{Smtp}}\index{Smtp@{Smtp}!L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+B\+O\+DY@{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+B\+O\+DY}}\item[{\em L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+B\+O\+DY\hypertarget{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a38fba41f28d754e38079b31418a86a69}{}\label{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a38fba41f28d754e38079b31418a86a69} }]sent the email body \index{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+Q\+U\+IT@{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+Q\+U\+IT}!Smtp@{Smtp}}\index{Smtp@{Smtp}!L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+Q\+U\+IT@{L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+Q\+U\+IT}}\item[{\em L\+G\+S\+S\+M\+T\+P\+\_\+\+S\+E\+N\+T\+\_\+\+Q\+U\+IT\hypertarget{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a2c2ed16ffc572326e3040684084b21d5}{}\label{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a2c2ed16ffc572326e3040684084b21d5} }]sent the session quit \end{description} \end{Desc} \begin{DoxyCode} 3897 \{ 3898 \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a29e5b0ecf75375b5a643faa3d6222b7c}{LGSSMTP\_IDLE}, 3899 \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0ab89442b7a3ca2b94c3cdcf33756eb933}{LGSSMTP\_CONNECTING}, 3900 \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0ab61778f70ecac007b334bb14942eb41d}{LGSSMTP\_CONNECTED}, 3901 \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a1dfec948a864205cec875f63cbe0d4ad}{LGSSMTP\_SENT\_HELO}, 3902 \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a929bb4623ff3f585108aba2a1b047fab}{LGSSMTP\_SENT\_FROM}, 3903 \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0aae20a0cb95b97a70f6b45d0ed2d5be83}{LGSSMTP\_SENT\_TO}, 3904 \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a85e3c452950c09a79086bff4b9be5c14}{LGSSMTP\_SENT\_DATA}, 3905 \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a38fba41f28d754e38079b31418a86a69}{LGSSMTP\_SENT\_BODY}, 3906 \hyperlink{group__smtp_gga116be79bf44f9dc2a97f46e051fe4dc0a2c2ed16ffc572326e3040684084b21d5}{LGSSMTP\_SENT\_QUIT}, 3907 \}; \end{DoxyCode} \subsection{Function Documentation} \index{Smtp@{Smtp}!lws\+\_\+email\+\_\+check@{lws\+\_\+email\+\_\+check}} \index{lws\+\_\+email\+\_\+check@{lws\+\_\+email\+\_\+check}!Smtp@{Smtp}} \subsubsection[{\texorpdfstring{lws\+\_\+email\+\_\+check(struct lws\+\_\+email $\ast$email)}{lws\_email\_check(struct lws\_email *email)}}]{\setlength{\rightskip}{0pt plus 5cm}L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN void lws\+\_\+email\+\_\+check ( \begin{DoxyParamCaption} \item[{struct {\bf lws\+\_\+email} $\ast$}]{email} \end{DoxyParamCaption} )}\hypertarget{group__smtp_ga5e535e346d92a9daf00be33abf79d4eb}{}\label{group__smtp_ga5e535e346d92a9daf00be33abf79d4eb} {\ttfamily \#include $<$\hyperlink{libwebsockets_8h}{lib/libwebsockets.\+h}$>$} \hyperlink{group__smtp_ga5e535e346d92a9daf00be33abf79d4eb}{lws\+\_\+email\+\_\+check()} -\/ Request check for new email \begin{DoxyParams}{Parameters} {\em email} & struct \hyperlink{structlws__email}{lws\+\_\+email} context to check\\ \hline \end{DoxyParams} Schedules a check for new emails in 1s... call this when you have queued an email for send. \index{Smtp@{Smtp}!lws\+\_\+email\+\_\+destroy@{lws\+\_\+email\+\_\+destroy}} \index{lws\+\_\+email\+\_\+destroy@{lws\+\_\+email\+\_\+destroy}!Smtp@{Smtp}} \subsubsection[{\texorpdfstring{lws\+\_\+email\+\_\+destroy(struct lws\+\_\+email $\ast$email)}{lws\_email\_destroy(struct lws\_email *email)}}]{\setlength{\rightskip}{0pt plus 5cm}L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN void lws\+\_\+email\+\_\+destroy ( \begin{DoxyParamCaption} \item[{struct {\bf lws\+\_\+email} $\ast$}]{email} \end{DoxyParamCaption} )}\hypertarget{group__smtp_ga25298a5afc1074e13b2d5711a86432b2}{}\label{group__smtp_ga25298a5afc1074e13b2d5711a86432b2} {\ttfamily \#include $<$\hyperlink{libwebsockets_8h}{lib/libwebsockets.\+h}$>$} \hyperlink{group__smtp_ga25298a5afc1074e13b2d5711a86432b2}{lws\+\_\+email\+\_\+destroy()} -\/ stop using the struct \hyperlink{structlws__email}{lws\+\_\+email} \begin{DoxyParams}{Parameters} {\em email} & the struct \hyperlink{structlws__email}{lws\+\_\+email} context\\ \hline \end{DoxyParams} Stop sending email using email and free allocations \index{Smtp@{Smtp}!lws\+\_\+email\+\_\+init@{lws\+\_\+email\+\_\+init}} \index{lws\+\_\+email\+\_\+init@{lws\+\_\+email\+\_\+init}!Smtp@{Smtp}} \subsubsection[{\texorpdfstring{lws\+\_\+email\+\_\+init(struct lws\+\_\+email $\ast$email, uv\+\_\+loop\+\_\+t $\ast$loop, int max\+\_\+content)}{lws\_email\_init(struct lws\_email *email, uv\_loop\_t *loop, int max\_content)}}]{\setlength{\rightskip}{0pt plus 5cm}L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN int lws\+\_\+email\+\_\+init ( \begin{DoxyParamCaption} \item[{struct {\bf lws\+\_\+email} $\ast$}]{email, } \item[{uv\+\_\+loop\+\_\+t $\ast$}]{loop, } \item[{int}]{max\+\_\+content} \end{DoxyParamCaption} )}\hypertarget{group__smtp_ga77fc9b56a1bb39484844981ec375fc29}{}\label{group__smtp_ga77fc9b56a1bb39484844981ec375fc29} {\ttfamily \#include $<$\hyperlink{libwebsockets_8h}{lib/libwebsockets.\+h}$>$} \hyperlink{group__smtp_ga77fc9b56a1bb39484844981ec375fc29}{lws\+\_\+email\+\_\+init()} -\/ Initialize a struct \hyperlink{structlws__email}{lws\+\_\+email} \begin{DoxyParams}{Parameters} {\em email} & struct \hyperlink{structlws__email}{lws\+\_\+email} to init \\ \hline {\em loop} & libuv loop to use \\ \hline {\em max\+\_\+content} & max email content size\\ \hline \end{DoxyParams} Prepares a struct \hyperlink{structlws__email}{lws\+\_\+email} for use ending S\+M\+TP