• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Forwarded to devs mailhandler ignores small info text in case of REJECT

hitd

Basic Pleskian
Username:

TITLE

mailhandler ignores small info text in case of REJECT

PRODUCT, VERSION, OPERATING SYSTEM, ARCHITECTURE

plesk obsidian linux, 18.0.42 Debian 10 - 64 bit, postfix

PROBLEM DESCRIPTION

See following smtp session:

Code:
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 220 puck983.startdedicated.de ESMTP Postfix (Debian/GNU)
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> EHLO foxtrot452.startdedicated.de
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 250-puck983.startdedicated.de
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 250-PIPELINING
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 250-SIZE 10240000
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 250-ETRN
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 250-STARTTLS
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 250-AUTH DIGEST-MD5 CRAM-MD5 PLAIN LOGIN
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 250-ENHANCEDSTATUSCODES
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 250-8BITMIME
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 250-DSN
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 250-SMTPUTF8
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 250 CHUNKING
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> MAIL FROM:<[email protected]>
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 250 2.1.0 Ok
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> RCPT TO:<[email protected]>
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 250 2.1.5 Ok
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> DATA
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 354 End data with <CR><LF>.<CR><LF>
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> Content-Disposition: inline
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> Content-Transfer-Encoding: 8bit
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> Content-Type: text/plain; charset=utf-8
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> MIME-Version: 1.0
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> X-Mailer: MIME::Lite 3.030 (F2.85; T2.17; A2.20; B3.15; Q3.13)
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> Date: Sat, 8 May 2021 09:34:27 +0200
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> From: [email protected]
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> To: [email protected]
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> Subject: virustest eicar
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> test ohne eicar-virus
MIME::Lite::SMTP=GLOB(0x564b72abadc0)>>> .
MIME::Lite::SMTP=GLOB(0x564b72abadc0)<<< 550 5.7.1 Command rejected
sending failed: Net::CMD (Net::SMTP) DATAEND command failed.
Last server message was:5.7.1 Command rejected

Mailhandler was:

Perl:
#! /usr/bin/perl -wtT
#

use strict;

use warnings;

print STDERR "REJECT\n";
print STDOUT "this should be seen during REJECT\n";

exit 1;

The other side should see "550 5.7.1 Command rejected - this should be seen during REJECT", not a reject without any comment. IIRC this works fine on earlier versions of plesk.



states:

The handler should only write to its standard output after writing PASS or REJECT on the standard error.

For PASS, the output should be a message in the same format as found on input.

I tested this a long time ago, and found in case of REJECT STDOUT is transmitted within the answer to SMTP command.

STEPS TO REPRODUCE

install mailhandler (perl) ( code above) in /usr/local/bin/test and make it executable

Execute following in bash

Bash:
#! /bin/bash
#
# should called with domain.tld as parameter.like
# 
# test-on-script example.com
# ins Verzeichnis wechseln
cd /usr/local/psa/admin/bin

CFG=`echo "$1" | tr "." "_"`

# Mailhandler zuweisen
./mail_handlers_control --add --priority=35 --name=test --mailname=$1 --queue=before-queue --type=recipient-domain --executable=/usr/l
ocal/bin/test --context=/usr/local/etc/test.d/${CFG}.ini

./mail_handlers_control --enable --priority=35 --name=test --mailname=$1 --queue=before-queue --type=recipient-domain --executable=/us
r/local/bin/test --context=/usr/local/etc/test.d/${CFG}.ini


exit 0

ACTUAL RESULT

550 5.7.1 Command rejected

EXPECTED RESULT

550 5.7.1 Command rejected this should be seen during REJECT

or

550-5.7.1 Command rejected
550 this should be seen during REJECT

probably the 2nd form ( multiline answer) is expected to use.

ANY ADDITIONAL INFORMATION

(DID NOT ANSWER QUESTION)

YOUR EXPECTATIONS FROM PLESK SERVICE TEAM

Confirm bug
 
sorry:
fix
STEPS TO REPRODUCE

install mailhandler (perl) ( code above) in /usr/local/bin/test and make it executable

to
STEPS TO REPRODUCE

install mailhandler (perl) ( code above) AS /usr/local/bin/test and make it executable
 
Just found the old doc


states:

Handler Output​

The handler is expected to produce the following output on standard error:

  • PASS. The message should be passed further. The handler should write the message, possibly modified, on the standard output.
  • STOP. The message should not be passed further but this is not an error. This should be used when the handler implements its own custom delivery instead of the delivery provided by the MTA. Subsequent handlers won't be called.
  • DEFER. The message should not be passed further. A temporary error condition should be indicated. Subsequent handlers won't be called.
  • REJECT. The message should not be passed further. A permanent error condition should be indicated. The handler should write a human-readable description of the error condition to the standard output. Subsequent handlers won't be called.
  • LOG text. The line of text should be treated as a warning or error message and added to the appropriate log.


Each line of output on the standard error should end with LF. After the first PASS, STOP, DEFER, or REJECT line, further output is not accepted, so any LOG lines must precede the above.

The handler should only write to its standard output after writing PASS or REJECT on the standard error.

For PASS, the output should be a message in the same format as found on input.

For REJECT, the output should be a description of the error condition. The description will be included in the SMTP error reply (if the handler is called before queuing, or in the bounce message (at other hooking points).

The exit code from the handler should be 0 on PASS or STOP and not 0 in other cases.

Here was described: write to STDOUT after REJECT leads to be included in SMTP error reply.

Later at about Plesk 9 this went away. However, its not forbidden by RFC. Someone can simply REJECT without any description of the cause. But in real life this is ugly. Other side is using phone and ask why we reject their mail. we had to check the log and answer. In the Plesk 8.6 variant, it was included in the delivery failed message, so they disinfect their system, no need to ask.

Peter
 
It's possible to add a custom message. For example:
Code:
# cat /usr/local/bin/test
#! /usr/bin/perl -wtT
#
 
use strict;
 
use warnings;
 
print STDERR "DATA REPLY:550:5.7.1 Command rejected my custom message\n";
print STDERR "REJECT\n";
 
 
exit 1;

The output will be:

Code:
<** 550 5.7.1 Command rejected my custom message
 -> QUIT
<-  221 2.0.0 Bye

Similar python and bash scripts can be found in Resolved - Mail-Handler - REJECT with message?
 
Thank you!
I will try next days and give a small report.
 
Last edited by a moderator:
Back
Top