Skip to content

Commit

Permalink
Update SpamTestSpamAssassin.cpp
Browse files Browse the repository at this point in the history
SpamAssassin Envelope-Sender

Use Envelope-Sender header in favour of first adding and later removing the Return-Path Header for use with SpamAssassin

This basically undo's this pull #hmailserver#116
  • Loading branch information
RvdHout committed Apr 24, 2021
1 parent 17c026f commit 1724108
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions hmailserver/source/Server/Common/AntiSpam/SpamTestSpamAssassin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,11 @@ namespace HM
std::shared_ptr<Message> pMessage = pTestData->GetMessageData()->GetMessage();
const String sFilename = PersistentMessage::GetFileName(pMessage);

// Add Return-Path header if none exist (ExternalAccount download?)
if (pTestData->GetMessageData()->GetReturnPath().IsEmpty())
{
String sEnvelopeFrom = pTestData->GetEnvelopeFrom();

std::vector<std::pair<AnsiString, AnsiString> > fieldsToWrite;
fieldsToWrite.push_back(std::make_pair("Return-Path", sEnvelopeFrom));
TraceHeaderWriter writer;
writer.Write(sFilename, pMessage, fieldsToWrite);
}
// Add envelope-from header "Envelope-From"
std::vector<std::pair<AnsiString, AnsiString> > fieldsToWrite;
fieldsToWrite.push_back(std::make_pair("Envelope-From", pTestData->GetEnvelopeFrom()));
TraceHeaderWriter writer;
writer.Write(sFilename, pMessage, fieldsToWrite);

std::shared_ptr<IOService> pIOService = Application::Instance()->GetIOService();

Expand Down Expand Up @@ -116,12 +111,7 @@ namespace HM

// Check if the message is tagged as spam.
std::shared_ptr<MessageData> pMessageData = pTestData->GetMessageData();

pMessageData->RefreshFromMessage();
// The Return-Path header was added above to help SpamAssassin with its SPF checks.
// We should remove it again to restore the headers to original state (except for any added by SA).
pMessageData->DeleteField("Return-Path");
pMessageData->Write(sFilename);

bool bIsSpam = false;
AnsiString sSpamStatus = pMessageData->GetFieldValue("X-Spam-Status");
Expand Down

0 comments on commit 1724108

Please sign in to comment.