Skip to content

Commit

Permalink
HPCC-30377 SendEmail exception while reading from mail server
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Kelly <mark.kelly@lexisnexisrisk.com>
  • Loading branch information
mckellyln committed Oct 23, 2023
1 parent 12967e2 commit eacd995
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions common/remote/rmtsmtp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,17 @@ class CMailInfo
lastAction.clear().append(action);
else
lastAction.clear().append(len, out).clip();

// read any remaining bytes ...
try
{
socket->readtms(inbuff, 0, sizeof(inbuff), inlen, 0);
}
catch(IException * e)
{
e->Release();
}

try
{
socket->write(out, len);
Expand All @@ -549,15 +560,15 @@ class CMailInfo
{
try
{
socket->read(inbuff,1,sizeof(inbuff),inlen);
socket->readtms(inbuff, 1, sizeof(inbuff), inlen, 30000);

//MORE: the following is somewhat primitive and not RFC compliant (see bug 25951) - but it is a lot better than nothing
if((*inbuff == '4') || (*inbuff == '5'))
{
StringBuffer b;
b.append("Negative reply from mail server at ").append(mailServer.get()).append(":").append(port).append(" after writing ").append(lastAction.str()).append(" in SendEmail*: ").append(inlen, inbuff).clip();
WARNLOG("%s", b.str());
if (warnings)
warnings->append(b.str());
b.append("Exception: negative reply from mail server at ").append(mailServer.get()).append(":").append(port).append(" after writing ").append(lastAction.str()).append(" in SendEmail*: ").append(inlen, inbuff).clip();
// don't continue on after these responses ...
throw makeStringException(MSGAUD_operator, 0, b.str());
}
#ifdef SMTP_TRACE
else
Expand Down

0 comments on commit eacd995

Please sign in to comment.