From 7359ef201a9506bf7c93e912fd711623def91b1c Mon Sep 17 00:00:00 2001 From: "Bruno G. Albuquerque" Date: Sun, 15 May 2005 13:57:03 +0000 Subject: [PATCH] Got SMTP to work with some broken SMTP servers. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12671 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../mail_daemon/outbound_protocols/smtp/smtp.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/add-ons/mail_daemon/outbound_protocols/smtp/smtp.cpp b/src/add-ons/mail_daemon/outbound_protocols/smtp/smtp.cpp index 18a808d050..835115e36e 100644 --- a/src/add-ons/mail_daemon/outbound_protocols/smtp/smtp.cpp +++ b/src/add-ons/mail_daemon/outbound_protocols/smtp/smtp.cpp @@ -921,6 +921,9 @@ SMTPProtocol::ReceiveResponse(BString &out) int32 len = 0,r; char buf[SMTP_RESPONSE_SIZE]; bigtime_t timeout = 1000000*180; // timeout 180 secs + bool gotCode = false; + int32 errCode; + BString searchStr = ""; struct timeval tv; struct fd_set fds; @@ -953,10 +956,21 @@ SMTPProtocol::ReceiveResponse(BString &out) r = recv(_fd,buf, SMTP_RESPONSE_SIZE - 1,0); if (r <= 0) break; + + if (!gotCode) + { + if (buf[3] == ' ' || buf[3] == '-') + { + errCode = atol(buf); + gotCode = true; + searchStr << errCode << ' '; + } + } len += r; out.Append(buf, r); - if (strstr(buf, CRLF)) + + if (strstr(buf, CRLF) && (out.FindFirst(searchStr) != B_ERROR)) break; } } else