void SpamAssassinClient::OnConnected() { // We'll handle all incoming data as binary. SetReceiveBinary(true); message_size_ = FileUtilities::FileSize(message_file_); EnqueueWrite("PROCESS SPAMC/1.2\r\n"); //LOG_DEBUG("SENT: PROCESS SPAMC/1.2"); String sConLen; sConLen.Format(_T("Content-length: %d\r\n"), message_size_); EnqueueWrite(sConLen); EnqueueWrite("\r\n"); SendFileContents_(message_file_); }
void POP3ClientConnection::EnqueueWrite_(const String &sData) { LogPOP3String_(sData, true); EnqueueWrite(sData + "\r\n"); }
void SMTPClientConnection::EnqueueWrite_(const String &sData) { LogSentCommand_(sData); if (current_state_ == PASSWORDSENT) last_sent_data_ = _T("<Password removed>"); else { last_sent_data_ = sData; } EnqueueWrite(sData + "\r\n"); }
void TCPConnection::EnqueueWrite(const AnsiString &sData) { AnsiString sTemp = sData; char *pBuf = sTemp.GetBuffer(); std::shared_ptr<ByteBuffer> pBuffer = std::shared_ptr<ByteBuffer>(new ByteBuffer()); pBuffer->Add((BYTE*) pBuf, sData.GetLength()); #ifdef _DEBUG String sDebugOutput; sDebugOutput.Format(_T("SENT: %s"), String(sTemp).c_str()); OutputDebugString(sDebugOutput); #endif EnqueueWrite(pBuffer); }
bool SpamAssassinClient::SendFileContents_(const String &sFilename) { String logMessage; logMessage.Format(_T("Sending message to SpamAssassin. Session %d, File: %s"), GetSessionID(), sFilename.c_str()); LOG_DEBUG(logMessage); File oFile; try { oFile.Open(sFilename, File::OTReadOnly); } catch (...) { String sErrorMsg; sErrorMsg.Format(_T("Could not send file %s via socket since the file could not be opened."), sFilename.c_str()); ErrorManager::Instance()->ReportError(ErrorManager::High, 5019, "SMTPClientConnection::SendFileContents_", sErrorMsg); return false; } const int maxIterations = 100000; for (int i = 0; i < maxIterations; i++) { std::shared_ptr<ByteBuffer> pBuf = oFile.ReadChunk(20000); if (pBuf->GetSize() == 0) break; BYTE *pSendBuffer = (BYTE*) pBuf->GetBuffer(); size_t iSendBufferSize = pBuf->GetSize(); EnqueueWrite(pBuf); } EnqueueShutdownSend(); // Request the response... EnqueueRead(""); return true; }