Author: tschoening Date: Sun Feb 9 19:50:54 2014 New Revision: 1566379 URL: http://svn.apache.org/r1566379 Log: LOGCXX-358: SMTPAppender generating Emails with an empty body
Modified: incubator/log4cxx/trunk/src/changes/changes.xml incubator/log4cxx/trunk/src/main/cpp/smtpappender.cpp Modified: incubator/log4cxx/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/changes/changes.xml?rev=1566379&r1=1566378&r2=1566379&view=diff ============================================================================== --- incubator/log4cxx/trunk/src/changes/changes.xml (original) +++ incubator/log4cxx/trunk/src/changes/changes.xml Sun Feb 9 19:50:54 2014 @@ -58,6 +58,7 @@ <action issue="LOGCXX-336" type="fix">Test compilation fails: Overloading ambiguity</action> <action issue="LOGCXX-340" type="fix">Transcoder::encodeCharsetName bungles encoding</action> <action issue="LOGCXX-351" type="fix">Download page does not have link to KEYS file</action> + <action issue="LOGCXX-358" type="fix">SMTPAppender generating Emails with an empty body</action> <action issue="LOGCXX-365" type="fix">Unit tests fail on system dates later than 2009-12-31.</action> <action issue="LOGCXX-366" type="fix">Errors when compile log4cxx 0.10.0 under Win7 x64 with Visual Studio 2010 (due to Christian Boos and Feng Nan)</action> <action issue="LOGCXX-367" type="fix">Build fails on Linux with g++ 4.4</action> Modified: incubator/log4cxx/trunk/src/main/cpp/smtpappender.cpp URL: http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/main/cpp/smtpappender.cpp?rev=1566379&r1=1566378&r2=1566379&view=diff ============================================================================== --- incubator/log4cxx/trunk/src/main/cpp/smtpappender.cpp (original) +++ incubator/log4cxx/trunk/src/main/cpp/smtpappender.cpp Sun Feb 9 19:50:54 2014 @@ -163,6 +163,7 @@ namespace log4cxx { const LogString msg, Pool& p) { message = smtp_add_message(session); body = current = toMessage(msg, p); + messagecbState = 0; smtp_set_reverse_path(message, toAscii(from, p)); addRecipients(to, "To", p); addRecipients(cc, "Cc", p); @@ -181,6 +182,7 @@ namespace log4cxx { smtp_message_t message; const char* body; const char* current; + int messagecbState; void addRecipients(const LogString& addresses, const char* field, Pool& p) { if (!addresses.empty()) { char* str = p.pstrdup(toAscii(addresses, p));; @@ -263,6 +265,10 @@ namespace log4cxx { if (len == NULL) { pThis->current = pThis->body; } else { + // we are asked for headers, but we don't have any + if ((pThis->messagecbState)++ == 0) { + return NULL; + } if (pThis->current) { *len = strlen(pThis->current); }