change SMTP status code for rejected mails
SMTP email proxy and relay server
Brought to you by:
graeme_walker
Hi,
is there any way to send different SMTP response code to clients after running the filters?
its needed in filtering mode because 452 code causes retry in mail server side but 5xx codes not.
in gsmtp/gsmtpserversend.cpp file you comment it but not implemented.
void GSmtp::ServerSend::sendCompletionReply( bool ok , const std::string & response )
{
if( ok )
sendOk( "message processed" ) ;
else
// 452=>"action not taken", or perhaps 554=>"transaction failed" (so don't try again)
send( "452 " + response ) ;
}
my suggestion; if exit code is 1 or any other value or range return 550/554 otherwise return 452
Yes, it makes sense to allow the filter to choose between 4xx and 5xx, but I think I would prefer to use the error response text rather than the exit code. The response that the filter prints to stdout inside double angle brackets or double square brackets could then be "<<554 rejected>>".
The required code changes would intersect with this https://sourceforge.net/p/emailrelay/support-requests/88/#108c which is now on the V_2_5_1 branch.
error response is ok, agree and I'm using.
but, as you know smtp clients use these codes.
if I return 4xx code to mail server after filter result it will try it again and again but when I send 5xx code it not try again.
so as result, allow the filter to choose SMTP code would be good like response text.
I think you mis-understood. I am proposing a change that allows the filter to choose the response code by extending the existing mechanism used for the response text.
Instead of this (in a shell-script filter):
you can do this:
Patch attached for the sf V_2_5_1 branch.
I tested emailrelay-2.5p1.exe and emailrelay-2.5p2.exe with below filter;
but the response code same, it just add my code as response text;
also I test filter with network filter on socket but the response same.
am I miss any detail?
Last edit: Yunus YILDIRIM 2023-09-26
Those executables do not contain the relevant patch.
Try this one:
https://sourceforge.net/projects/emailrelay/files/OldFiles/emailrelay-2.5.1rc2.exe/download
excellent. it worked.
Thanks a lot.
hi again,
when I try to do same thing with network filter its not work.
I try to send "[[550 Rejected for policy reasons]]" or "<<550 Rejected for policy reasons>>" as response over socket. the emailrelay return "452 [[[550 Rejected for policy reasons]]" as response.
also I try to send "550 Rejected for policy reasons" as response and SMTP code not work too.
this message return "550 550" as SMTP code and message. not my error message with SMTP code
Last edit: Yunus YILDIRIM 2023-10-25
The network filter does not use double angle-bracket or double square-bracket delimiters. (The reason for them is because the scripting run-time can emit all sorts of junk that is not under the script's control -- like the microsoft copyright banners.) In a network filter just send "550 rejected" or whatever without the brackets.
I try this one also, as I said in previous message, but it didnt work.
in attachment you will see my response over network filter and smtp server message. also I add my simple python network filter script
The relevant code was committed on September 27th. Is your test executable later that that?
yes. filename is emailrelay-2.5.1rc2.exe
here is therelevant emailrelay log lines;
Okay, thanks for testing: there is a bug on line 129 of gnetworkfilter.cpp. The erase() should have zero as its first parameter.
hi,
will be any release for this one?
It's ready for release, except that I wanted to rework the windows build procedure before publishing binaries. It's not going particularly well, so I think I'll revert that and hopefully get the release out over the weekend.
Now released.