• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

.qmail-command exit codes not working in 11.5

rjshelq

New Pleskian
Ive just upgraded from 11.0.9 to Plesk 11.5.30 Update #13 and qmail now has a very troublesome error.

In qmail (and in all previous versions of Plesk Panel) the .qmail file accepts commands, which tell qmail-local what to do with the mail message. Commands (which must begin with the pipe symbol) are run as shell programs, and qmail-local determines what should happen next according to the exit code of the command. (See dot-qmail(5) and qmail-command(8) man pages for full details of how the command should work.)

However, Plesk qmail now fails to properly respond to any of the qmail exit codes.

Here are the results of the four command exit codes which are defined in the qmail documentation:

Exit Code 0: Now the email message remains stuck in queue, undelivered. (According to qmail spec, this should have indicated a successful command completion, and the message should move on to the next command.)

Exit Code 99: Now the email message is immediately passed through to next command. (According to qmail spec, this should indicate a successful command completion, but all further commands should be ignored.)

Exit Code 100: Now the email message is immediately passed through to next command. (According to qmail spec, this should indicate that the delivery has a permanent failure and should not be retried.)

Exit Code 111: Now the email message is immediately passed through to next command. (According to qmail spec, this should indicate that the delivery has a temporary failure and should be retried in a little while.)
 
Are you still using outdated QMail and even edit .qmail files? What for?

P.S.: just checked with exit code 99 and it works flawlessly. Maybe you can provide more details / exact steps to reproduce? "remains stuck in queue" hints that maybe you have broken mail subsystem, try repairing it with mchk / mail_restore.
 
I've been using qmail for about 15 years, and really have no pressing need to change. I like qmail because it is simple, fast, reliable and it does exactly what I need... or rather up until this last update to Plesk 11.5.30 it did exactly what I need.

Yes, I have run mchk to no avail. Please note that it appears that Parallels has modified the qmail-local file and the qmail-queue file. My old qmail-local file (from Plesk 11.0.5) was 43248 bytes, the new file (in Plesk 11.5.30) is 47856 bytes. The old qmail-queue file was 20880 bytes, and the new file is 49648 bytes. Apparently some change in those new qmail files has caused this problem.

I use commands (perl scripts) in the .qmail file to do some mail screening and bounce processing. But now, as of this update, qmail no longer responds properly to the exit code of the scripts. It makes me wonder if perhaps Parallels has added some sort of handler between qmail-local and the .qmail files.

Without any added commands in the .qmail file, all mail processing works fine. So, qmail seems to be running correctly, until an additional command is added to the .qmail file.

Steps to reproduce:

I'm using CentOS 5.9 with Plesk 11.5.30 update #13 (as of sep 16, 2013 this is the latest version recommended by my provider).


1) Modify a .qmail file as follows.

Original .qmail file:

| true
| /usr/bin/deliverquota ./Maildir

Modified .qmail file:

| perl_exit_code.pl
| /usr/bin/deliverquota ./Maildir


2) Add a simple perl script for testing. For simplicity in this test, just add this script to the same directory as the .qmail file.


perl script:

#!/usr/bin/perl -w
use strict;
my $exit_code = 0;
exit $exit_code;


After adding the script file, chown popuser:popuser and chmod 777 so that that there cannot be any permissions issue.


3) Send an email to that email account. Then verify the contents of the queue and the Maildir. (Note: qmHandle is a handy utility for checking the queue and message content)

When $exit_code = 0 the expected result is that the message will be removed from the queue, and successfully delivered to Maildir. However, the current result is that the message is held in the queue, and is not delivered to Maildir.


4) Next, change the $exit_code to 99 in the perl script (my $exit_code = 99;) and send another email to that account. Verify the contents of the queue and the Maildir.

perl script:

#!/usr/bin/perl -w
use strict;
my $exit_code = 99;
exit $exit_code;

When $exit_code = 99 the expected result is that the message will be removed from the queue, but will not be delivered to Maildir. However, the current result is that the message is removed from the queue, but is erroneously delivered to Maildir.


References:

Here are the relevant portions of the qmail man pages for dot-qmail and qmail-command.

**********


NAME
dot-qmail - control the delivery of mail messages

DESCRIPTION
Normally the qmail-local program delivers each incoming
message to your system mailbox, homedir/Mailbox, where
homedir is your home directory.

It can instead write the mail to a different file or
directory, forward it to another address, distribute it to a
mailing list, or even execute programs, all under your
control.

THE QMAIL FILE
To change qmail-local's behavior, set up a .qmail file in
your home directory.

.qmail contains one or more lines. Each line is a delivery
instruction. qmail-local follows each instruction in turn.
There are five types of delivery instructions: (1) comment;
(2) program; (3) forward; (4) mbox; (5) maildir.

(1) A comment line begins with a number sign:

# this is a comment

qmail-local ignores the line.

(2) A program line begins with a vertical bar:

|preline /usr/ucb/vacation djb

qmail-local takes the rest of the line as a command to
supply to sh. See qmail-command(8) for further
information.


**********

NAME
qmail-command - user-specified mail delivery program

SYNOPSIS
in .qmailext: |command

DESCRIPTION
qmail-local will, upon your request, feed each incoming mail
message through a program of your choice.

When a mail message arrives, qmail-local runs sh -c command
in your home directory. It makes the message available on
command's standard input.

WARNING: The mail message does not begin with qmail-local's
usual Return-Path and Delivered-To lines.

Note that qmail-local uses the same file descriptor for
every delivery in your .qmail file, so it is not safe for
command to fork a child that reads the message in the
background while the parent exits.

EXIT CODES
command's exit codes are interpreted as follows: 0 means
that the delivery was successful; 99 means that the delivery
was successful, but that qmail-local should ignore all
further delivery instructions; 100 means that the delivery
failed permanently (hard error); 111 means that the delivery
failed but should be tried again in a little while (soft
error).


*****************************
 
Last edited:
Did you look in the logs before posting? I get this (which is quite predictable):

qmail: 1379577482.712251 delivery 4: deferral: /bin/sh:_perl_exit_code.pl:_command_not_found/

Here's a handy advice - don't use relative paths in .qmail files. Or if you do, do it properly, like so:

# cat .qmail
| ./perl_exit_code.pl
| /usr/bin/deliverquota ./Maildir
 
It appears that there is now (as of Plesk 11.5) something different about the shell program running the .qmail files. Initially, after the upgrade to 11.5, my .qmail file included the full path to my email filters, but still got the error message that the file could not be found.

However, I've found that this style of command solves the problem, by simply adding the path to the interpreter:

| /usr/bin/perl perl_exit_code.pl
| /usr/bin/deliverquota ./Maildir
 
Back
Top