2 * This module is an SMTP and ESMTP implementation for the Citadel system.
3 * It is compliant with all of the following:
5 * RFC 821 - Simple Mail Transfer Protocol
6 * RFC 876 - Survey of SMTP Implementations
7 * RFC 1047 - Duplicate messages and SMTP
8 * RFC 1652 - 8 bit MIME
9 * RFC 1869 - Extended Simple Mail Transfer Protocol
10 * RFC 1870 - SMTP Service Extension for Message Size Declaration
11 * RFC 2033 - Local Mail Transfer Protocol
12 * RFC 2197 - SMTP Service Extension for Command Pipelining
13 * RFC 2476 - Message Submission
14 * RFC 2487 - SMTP Service Extension for Secure SMTP over TLS
15 * RFC 2554 - SMTP Service Extension for Authentication
16 * RFC 2821 - Simple Mail Transfer Protocol
17 * RFC 2822 - Internet Message Format
18 * RFC 2920 - SMTP Service Extension for Command Pipelining
20 * The VRFY and EXPN commands have been removed from this implementation
21 * because nobody uses these commands anymore, except for spammers.
23 * Copyright (c) 1998-2009 by the citadel.org team
25 * This program is free software; you can redistribute it and/or modify
26 * it under the terms of the GNU General Public License as published by
27 * the Free Software Foundation; either version 3 of the License, or
28 * (at your option) any later version.
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public License
36 * along with this program; if not, write to the Free Software
37 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
49 #include <sys/types.h>
52 #if TIME_WITH_SYS_TIME
53 # include <sys/time.h>
57 # include <sys/time.h>
66 #include <sys/socket.h>
67 #include <netinet/in.h>
68 #include <arpa/inet.h>
69 #include <libcitadel.h>
72 #include "citserver.h"
79 #include "internet_addressing.h"
82 #include "clientsocket.h"
83 #include "locate_host.h"
84 #include "citadel_dirs.h"
86 #include "ctdl_module.h"
88 #include "smtp_util.h"
89 #include "event_client.h"
90 #include "smtpqueue.h"
92 #ifdef EXPERIMENTAL_SMTP_EVENT_CLIENT
93 /*****************************************************************************/
94 /* SMTP CLIENT (OUTBOUND PROCESSING) STUFF */
95 /*****************************************************************************/
97 typedef enum _eSMTP_C_States {
111 const long SMTP_C_ConnTimeout = 60; /* wail 1 minute for connections... */
112 const long SMTP_C_ReadTimeouts[eMaxSMTPC] = {
113 300, /* Greeting... */
121 0, /* end of body... */
124 const long SMTP_C_SendTimeouts[eMaxSMTPC] = {
125 90, /* Greeting... */
133 900, /* end of body... */
137 const long SMTP_C_SendTimeouts[eMaxSMTPC] = {
140 static const ConstStr ReadErrors[eMaxSMTPC] = {
141 {HKEY("Connection broken during SMTP conversation")},
142 {HKEY("Connection broken during SMTP EHLO")},
143 {HKEY("Connection broken during SMTP HELO")},
144 {HKEY("Connection broken during SMTP AUTH")},
145 {HKEY("Connection broken during SMTP MAIL FROM")},
146 {HKEY("Connection broken during SMTP RCPT")},
147 {HKEY("Connection broken during SMTP DATA")},
148 {HKEY("Connection broken during SMTP message transmit")},
149 {HKEY("")}/* quit reply, don't care. */
153 typedef struct _stmp_out_msg {
154 MailQEntry *MyQEntry;
159 eSMTP_C_States State;
161 struct ares_mx_reply *AllMX;
162 struct ares_mx_reply *CurrMX;
166 struct hostent *OneMX;
178 void DeleteSmtpOutMsg(void *v)
182 ares_free_data(Msg->AllMX);
184 FreeStrBuf(&Msg->msgtext);
185 FreeAsyncIOContents(&Msg->IO);
189 eNextState SMTP_C_Timeout(AsyncIO *IO);
190 eNextState SMTP_C_ConnFail(AsyncIO *IO);
191 eNextState SMTP_C_DispatchReadDone(AsyncIO *IO);
192 eNextState SMTP_C_DispatchWriteDone(AsyncIO *IO);
193 eNextState SMTP_C_Terminate(AsyncIO *IO);
194 eReadState SMTP_C_ReadServerStatus(AsyncIO *IO);
196 typedef eNextState (*SMTPReadHandler)(SmtpOutMsg *Msg);
197 typedef eNextState (*SMTPSendHandler)(SmtpOutMsg *Msg);
200 #define SMTP_ERROR(WHICH_ERR, ERRSTR) do {\
201 SendMsg->MyQEntry->Status = WHICH_ERR; \
202 StrBufAppendBufPlain(SendMsg->MyQEntry->StatusMessage, HKEY(ERRSTR), 0); \
206 #define SMTP_VERROR(WHICH_ERR) do {\
207 SendMsg->MyQEntry->Status = WHICH_ERR; \
208 StrBufPlain(SendMsg->MyQEntry->StatusMessage, \
209 ChrPtr(SendMsg->IO.IOBuf) + 4, \
210 StrLength(SendMsg->IO.IOBuf) - 4); \
214 #define SMTP_IS_STATE(WHICH_STATE) (ChrPtr(SendMsg->IO.IOBuf)[0] == WHICH_STATE)
216 #define SMTP_DBG_SEND() CtdlLogPrintf(CTDL_DEBUG, "SMTP client[%ld]: > %s\n", SendMsg->n, ChrPtr(SendMsg->IO.IOBuf))
217 #define SMTP_DBG_READ() CtdlLogPrintf(CTDL_DEBUG, "SMTP client[%ld]: < %s\n", SendMsg->n, ChrPtr(SendMsg->IO.IOBuf))
220 void FinalizeMessageSend(SmtpOutMsg *Msg)
222 CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
224 if (DecreaseQReference(Msg->MyQItem))
229 nRemain = CountActiveQueueEntries(Msg->MyQItem);
231 MsgData = SerializeQueueItem(Msg->MyQItem);
233 * Uncompleted delivery instructions remain, so delete the old
234 * instructions and replace with the updated ones.
236 CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, &Msg->MyQItem->QueMsgID, 1, "");
237 smtpq_do_bounce(Msg->MyQItem,
240 struct CtdlMessage *msg;
241 msg = malloc(sizeof(struct CtdlMessage));
242 memset(msg, 0, sizeof(struct CtdlMessage));
243 msg->cm_magic = CTDLMESSAGE_MAGIC;
244 msg->cm_anon_type = MES_NORMAL;
245 msg->cm_format_type = FMT_RFC822;
246 msg->cm_fields['M'] = SmashStrBuf(&MsgData);
247 /* Generate 'bounce' messages */
248 smtp_do_bounce(msg->cm_fields['M'],
251 CtdlSubmitMsg(msg, NULL, SMTP_SPOOLOUT_ROOM, QP_EADDR);
252 CtdlFreeMessage(msg);
255 CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, &Msg->MyQItem->MessageID, 1, "");
257 RemoveQItem(Msg->MyQItem);
259 DeleteSmtpOutMsg(Msg);
265 void get_one_mx_host_ip_done(void *Ctx,
268 struct hostent *hostent)
271 SmtpOutMsg *SendMsg = IO->Data;
272 CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
273 if ((status == ARES_SUCCESS) && (hostent != NULL) ) {
274 unsigned long psaddr;
276 memcpy(&psaddr, hostent->h_addr_list[0], sizeof(psaddr));
277 psaddr = ntohl(psaddr);
279 CtdlLogPrintf(CTDL_DEBUG,
280 "SMTP client[%ld]: connecting to %s [%ld.%ld.%ld.%ld:%d] ...\n",
283 (psaddr >> 24) & 0xFF,
284 (psaddr >> 16) & 0xFF,
285 (psaddr >> 8) & 0xFF,
286 (psaddr >> 0) & 0xFF,
289 SendMsg->MyQEntry->Status = 5;
290 StrBufPrintf(SendMsg->MyQEntry->StatusMessage,
291 "Timeout while connecting %s [%ld.%ld.%ld.%ld:%d] ",
293 (psaddr >> 24) & 0xFF,
294 (psaddr >> 16) & 0xFF,
295 (psaddr >> 8) & 0xFF,
296 (psaddr >> 0) & 0xFF,
299 SendMsg->IO.HEnt = hostent;
300 InitEventIO(IO, SendMsg,
301 SMTP_C_DispatchReadDone,
302 SMTP_C_DispatchWriteDone,
306 SMTP_C_ReadServerStatus,
308 SMTP_C_ReadTimeouts[0],
314 const unsigned short DefaultMXPort = 25;
315 void get_one_mx_host_ip(SmtpOutMsg *SendMsg)
320 CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
321 SendMsg->IO.dport = DefaultMXPort;
325 *SendMsg->mx_user = '\0';
326 *SendMsg->mx_pass = '\0';
327 if (num_tokens(buf, '@') > 1) {
328 strcpy (SendMsg->mx_user, buf);
329 endpart = strrchr(SendMsg->mx_user, '@');
331 strcpy (SendMsg->mx_host, endpart + 1);
332 endpart = strrchr(SendMsg->mx_user, ':');
333 if (endpart != NULL) {
334 strcpy(SendMsg->mx_pass, endpart+1);
338 endpart = strrchr(SendMsg->mx_host, ':');
341 strcpy(SendMsg->mx_port, endpart + 1);
346 SendMsg->mx_host = SendMsg->CurrMX->host;
347 SendMsg->CurrMX = SendMsg->CurrMX->next;
349 CtdlLogPrintf(CTDL_DEBUG,
350 "SMTP client[%ld]: looking up %s : %d ...\n",
355 ares_gethostbyname(SendMsg->IO.DNSChannel,
357 AF_INET6, /* it falls back to ipv4 in doubt... */
358 get_one_mx_host_ip_done,
363 eNextState smtp_resolve_mx_done(AsyncIO *IO)
365 SmtpOutMsg * SendMsg = IO->Data;
367 CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
369 SendMsg->IO.SendBuf.Buf = NewStrBufPlain(NULL, 1024);
370 SendMsg->IO.RecvBuf.Buf = NewStrBufPlain(NULL, 1024);
371 SendMsg->IO.IOBuf = NewStrBuf();
372 SendMsg->IO.ErrMsg = SendMsg->MyQEntry->StatusMessage;
374 SendMsg->CurrMX = SendMsg->AllMX = IO->VParsedDNSReply;
375 //// TODO: should we remove the current ares context???
376 get_one_mx_host_ip(SendMsg);
381 int resolve_mx_records(void *Ctx)
383 SmtpOutMsg * SendMsg = Ctx;
385 CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
387 if (!QueueQuery(ns_t_mx,
390 smtp_resolve_mx_done))
392 SendMsg->MyQEntry->Status = 5;
393 StrBufPrintf(SendMsg->MyQEntry->StatusMessage,
394 "No MX hosts found for <%s>", SendMsg->node);
395 return 0; ///////TODO: abort!
401 int smtp_resolve_recipients(SmtpOutMsg *SendMsg)
409 CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
411 if ((SendMsg==NULL) ||
412 (SendMsg->MyQEntry == NULL) ||
413 (StrLength(SendMsg->MyQEntry->Recipient) == 0)) {
417 /* Parse out the host portion of the recipient address */
418 process_rfc822_addr(ChrPtr(SendMsg->MyQEntry->Recipient),
423 CtdlLogPrintf(CTDL_DEBUG, "SMTP client[%ld]: Attempting delivery to <%s> @ <%s> (%s)\n",
424 SendMsg->n, SendMsg->user, SendMsg->node, SendMsg->name);
425 /* If no envelope_from is supplied, extract one from the message */
426 if ( (SendMsg->envelope_from == NULL) ||
427 (IsEmptyStr(SendMsg->envelope_from)) ) {
428 SendMsg->mailfrom[0] = '\0';
430 ptr = ChrPtr(SendMsg->msgtext);
432 if (ptr = cmemreadline(ptr, buf, sizeof buf), *ptr == 0) {
435 if (!strncasecmp(buf, "From:", 5)) {
436 safestrncpy(SendMsg->mailfrom, &buf[5], sizeof SendMsg->mailfrom);
437 striplt(SendMsg->mailfrom);
438 for (i=0; SendMsg->mailfrom[i]; ++i) {
439 if (!isprint(SendMsg->mailfrom[i])) {
440 strcpy(&SendMsg->mailfrom[i], &SendMsg->mailfrom[i+1]);
445 /* Strip out parenthesized names */
448 for (i=0; !IsEmptyStr(SendMsg->mailfrom + i); ++i) {
449 if (SendMsg->mailfrom[i] == '(') lp = i;
450 if (SendMsg->mailfrom[i] == ')') rp = i;
452 if ((lp>0)&&(rp>lp)) {
453 strcpy(&SendMsg->mailfrom[lp-1], &SendMsg->mailfrom[rp+1]);
456 /* Prefer brokketized names */
459 for (i=0; !IsEmptyStr(SendMsg->mailfrom + i); ++i) {
460 if (SendMsg->mailfrom[i] == '<') lp = i;
461 if (SendMsg->mailfrom[i] == '>') rp = i;
463 if ( (lp>=0) && (rp>lp) ) {
464 SendMsg->mailfrom[rp] = 0;
465 memmove(SendMsg->mailfrom,
466 &SendMsg->mailfrom[lp + 1],
472 } while (scan_done == 0);
473 if (IsEmptyStr(SendMsg->mailfrom)) strcpy(SendMsg->mailfrom, "someone@somewhere.org");
474 stripallbut(SendMsg->mailfrom, '<', '>');
475 SendMsg->envelope_from = SendMsg->mailfrom;
483 void smtp_try(OneQueItem *MyQItem,
484 MailQEntry *MyQEntry,
486 int KeepMsgText, /* KeepMsgText allows us to use MsgText as ours. */
489 SmtpOutMsg * SendMsg;
491 CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
493 SendMsg = (SmtpOutMsg *) malloc(sizeof(SmtpOutMsg));
494 memset(SendMsg, 0, sizeof(SmtpOutMsg));
495 SendMsg->IO.sock = (-1);
496 SendMsg->n = MsgCount++;
497 SendMsg->MyQEntry = MyQEntry;
498 SendMsg->MyQItem = MyQItem;
499 SendMsg->IO.Data = SendMsg;
501 SendMsg->msgtext = MsgText;
503 SendMsg->msgtext = NewStrBufDup(MsgText);
505 if (smtp_resolve_recipients(SendMsg)) {
506 QueueEventContext(SendMsg,
511 if ((SendMsg==NULL) ||
512 (SendMsg->MyQEntry == NULL)) {
513 SendMsg->MyQEntry->Status = 5;
514 StrBufPlain(SendMsg->MyQEntry->StatusMessage,
515 HKEY("Invalid Recipient!"));
517 FinalizeMessageSend(SendMsg);
525 /*****************************************************************************/
526 /* SMTP CLIENT STATE CALLBACKS */
527 /*****************************************************************************/
528 eNextState SMTPC_read_greeting(SmtpOutMsg *SendMsg)
530 /* Process the SMTP greeting from the server */
533 if (!SMTP_IS_STATE('2')) {
534 if (SMTP_IS_STATE('4'))
542 eNextState SMTPC_send_EHLO(SmtpOutMsg *SendMsg)
544 /* At this point we know we are talking to a real SMTP server */
546 /* Do a EHLO command. If it fails, try the HELO command. */
547 StrBufPrintf(SendMsg->IO.SendBuf.Buf,
548 "EHLO %s\r\n", config.c_fqdn);
554 eNextState SMTPC_read_EHLO_reply(SmtpOutMsg *SendMsg)
558 if (SMTP_IS_STATE('2')) {
560 if (IsEmptyStr(SendMsg->mx_user))
561 SendMsg->State ++; /* Skip auth... */
563 /* else we fall back to 'helo' */
567 eNextState STMPC_send_HELO(SmtpOutMsg *SendMsg)
569 StrBufPrintf(SendMsg->IO.SendBuf.Buf,
570 "HELO %s\r\n", config.c_fqdn);
576 eNextState SMTPC_read_HELO_reply(SmtpOutMsg *SendMsg)
580 if (!SMTP_IS_STATE('2')) {
581 if (SMTP_IS_STATE('4'))
586 if (!IsEmptyStr(SendMsg->mx_user))
587 SendMsg->State ++; /* Skip auth... */
591 eNextState SMTPC_send_auth(SmtpOutMsg *SendMsg)
596 /* Do an AUTH command if necessary */
597 sprintf(buf, "%s%c%s%c%s",
598 SendMsg->mx_user, '\0',
599 SendMsg->mx_user, '\0',
601 CtdlEncodeBase64(encoded, buf,
602 strlen(SendMsg->mx_user) +
603 strlen(SendMsg->mx_user) +
604 strlen(SendMsg->mx_pass) + 2, 0);
605 StrBufPrintf(SendMsg->IO.SendBuf.Buf,
606 "AUTH PLAIN %s\r\n", encoded);
612 eNextState SMTPC_read_auth_reply(SmtpOutMsg *SendMsg)
614 /* Do an AUTH command if necessary */
618 if (!SMTP_IS_STATE('2')) {
619 if (SMTP_IS_STATE('4'))
627 eNextState SMTPC_send_FROM(SmtpOutMsg *SendMsg)
629 /* previous command succeeded, now try the MAIL FROM: command */
630 StrBufPrintf(SendMsg->IO.SendBuf.Buf,
631 "MAIL FROM:<%s>\r\n",
632 SendMsg->envelope_from);
638 eNextState SMTPC_read_FROM_reply(SmtpOutMsg *SendMsg)
642 if (!SMTP_IS_STATE('2')) {
643 if (SMTP_IS_STATE('4'))
652 eNextState SMTPC_send_RCPT(SmtpOutMsg *SendMsg)
654 /* MAIL succeeded, now try the RCPT To: command */
655 StrBufPrintf(SendMsg->IO.SendBuf.Buf,
656 "RCPT TO:<%s@%s>\r\n",
664 eNextState SMTPC_read_RCPT_reply(SmtpOutMsg *SendMsg)
668 if (!SMTP_IS_STATE('2')) {
669 if (SMTP_IS_STATE('4'))
677 eNextState SMTPC_send_DATAcmd(SmtpOutMsg *SendMsg)
679 /* RCPT succeeded, now try the DATA command */
680 StrBufPlain(SendMsg->IO.SendBuf.Buf,
687 eNextState SMTPC_read_DATAcmd_reply(SmtpOutMsg *SendMsg)
691 if (!SMTP_IS_STATE('3')) {
692 if (SMTP_IS_STATE('4'))
700 eNextState SMTPC_send_data_body(SmtpOutMsg *SendMsg)
703 /* If we reach this point, the server is expecting data.*/
705 Buf = SendMsg->IO.SendBuf.Buf;
706 SendMsg->IO.SendBuf.Buf = SendMsg->msgtext;
707 SendMsg->msgtext = Buf;
708 //// TODO timeout like that: (SendMsg->msg_size / 128) + 50);
714 eNextState SMTPC_send_terminate_data_body(SmtpOutMsg *SendMsg)
718 Buf = SendMsg->IO.SendBuf.Buf;
719 SendMsg->IO.SendBuf.Buf = SendMsg->msgtext;
720 SendMsg->msgtext = Buf;
722 StrBufPlain(SendMsg->IO.SendBuf.Buf,
729 eNextState SMTPC_read_data_body_reply(SmtpOutMsg *SendMsg)
733 if (!SMTP_IS_STATE('2')) {
734 if (SMTP_IS_STATE('4'))
741 StrBufPlain(SendMsg->MyQEntry->StatusMessage,
742 &ChrPtr(SendMsg->IO.RecvBuf.Buf)[4],
743 StrLength(SendMsg->IO.RecvBuf.Buf) - 4);
744 SendMsg->MyQEntry->Status = 2;
748 eNextState SMTPC_send_QUIT(SmtpOutMsg *SendMsg)
750 StrBufPlain(SendMsg->IO.SendBuf.Buf,
757 eNextState SMTPC_read_QUIT_reply(SmtpOutMsg *SendMsg)
761 CtdlLogPrintf(CTDL_INFO, "SMTP client[%ld]: delivery to <%s> @ <%s> (%s) succeeded\n",
762 SendMsg->n, SendMsg->user, SendMsg->node, SendMsg->name);
763 return eTerminateConnection;
766 eNextState SMTPC_read_dummy(SmtpOutMsg *SendMsg)
771 eNextState SMTPC_send_dummy(SmtpOutMsg *SendMsg)
777 /*****************************************************************************/
778 /* SMTP CLIENT DISPATCHER */
779 /*****************************************************************************/
780 SMTPReadHandler ReadHandlers[eMaxSMTPC] = {
782 SMTPC_read_EHLO_reply,
783 SMTPC_read_HELO_reply,
784 SMTPC_read_auth_reply,
785 SMTPC_read_FROM_reply,
786 SMTPC_read_RCPT_reply,
787 SMTPC_read_DATAcmd_reply,
789 SMTPC_read_data_body_reply,
790 SMTPC_read_QUIT_reply
792 SMTPSendHandler SendHandlers[eMaxSMTPC] = {
793 SMTPC_send_dummy, /* we don't send a greeting, the server does... */
800 SMTPC_send_data_body,
801 SMTPC_send_terminate_data_body,
805 void SMTPSetTimeout(eNextState NextTCPState, SmtpOutMsg *pMsg)
807 CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
809 switch (NextTCPState) {
812 Timeout = SMTP_C_SendTimeouts[pMsg->State];
815 Timeout = SMTP_C_ReadTimeouts[pMsg->State];
817 case eTerminateConnection:
821 SetNextTimeout(&pMsg->IO, Timeout);
823 eNextState SMTP_C_DispatchReadDone(AsyncIO *IO)
825 CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
826 SmtpOutMsg *pMsg = IO->Data;
829 rc = ReadHandlers[pMsg->State](pMsg);
831 SMTPSetTimeout(rc, pMsg);
834 eNextState SMTP_C_DispatchWriteDone(AsyncIO *IO)
836 CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
837 SmtpOutMsg *pMsg = IO->Data;
840 rc = SendHandlers[pMsg->State](pMsg);
841 SMTPSetTimeout(rc, pMsg);
846 /*****************************************************************************/
847 /* SMTP CLIENT ERROR CATCHERS */
848 /*****************************************************************************/
849 eNextState SMTP_C_Terminate(AsyncIO *IO)
851 CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
852 SmtpOutMsg *pMsg = IO->Data;
853 FinalizeMessageSend(pMsg);
856 eNextState SMTP_C_Timeout(AsyncIO *IO)
858 CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
859 SmtpOutMsg *pMsg = IO->Data;
860 StrBufPlain(IO->ErrMsg, CKEY(ReadErrors[pMsg->State]));
861 FinalizeMessageSend(pMsg);
864 eNextState SMTP_C_ConnFail(AsyncIO *IO)
866 CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
867 SmtpOutMsg *pMsg = IO->Data;
868 FinalizeMessageSend(pMsg);
874 * @brief lineread Handler; understands when to read more SMTP lines, and when this is a one-lined reply.
876 eReadState SMTP_C_ReadServerStatus(AsyncIO *IO)
878 eReadState Finished = eBufferNotEmpty;
880 while (Finished == eBufferNotEmpty) {
881 Finished = StrBufChunkSipLine(IO->IOBuf, &IO->RecvBuf);
884 case eMustReadMore: /// read new from socket...
887 case eBufferNotEmpty: /* shouldn't happen... */
888 case eReadSuccess: /// done for now...
889 if (StrLength(IO->IOBuf) < 4)
891 if (ChrPtr(IO->IOBuf)[3] == '-')
892 Finished = eBufferNotEmpty;
896 case eReadFail: /// WHUT?
906 CTDL_MODULE_INIT(smtp_eventclient)
908 return "smtpeventclient";