The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Managing the Mail Queue Files and Directories

Posted by jpluimers on 2025/09/15

I wish I had found this overview eons ago: [Wayback/Archive] Managing the Mail Queue Files and Directories.

The most important bits on the various kinds of files that appear in your message queue:

Mail Queue Files

Each message in the queue has a number of files associated with it. The files are named according to the following conventions:
TypefID
where ID is a unique message queue ID, and Type is one of the following letters indicating the type of file:
d The data file containing the message body without the heading information.
q The queue-control file. This file contains the information necessary to process the job.
t A temporary file. This file is an image of the q file when it is being rebuilt. It is quickly renamed to the q file.
x A transcript file that exists during the life of a session and shows everything that happens during that session.
For example, if a message has a queue ID of AA00269, the following files are created and deleted in the mail queue directory while the sendmail command tries to deliver the message:
dfAA00269 Data file
qfAA00269 Control file
tfAA00269 Temporary file
xfAA00269 Transcript file

q Control File

The q control file contains a series of lines, each beginning with a code letter:
B Specifies the body type. The remainder of the line is a text string defining the body type. If this field is missing, the body type is assumed to be undefined, and no special processing is attempted. Legal values are 7BIT and 8BITMIME.
C Contains the controlling address. The syntax is localuser:aliasname. Recipient addresses following this line are flagged so that deliveries will run as the localuser (a user name from the /etc/passwd file); aliasname is the name of the alias that expanded to this address (used for printing messages).
F Contains flag bits represented as one letter per flag. Defined flag bits are r indicating that this is a response message and w indicating that a warning message has been sent announcing that mail has been delayed.
H Contains a heading definition. There may be any number of these lines. The order in which the H lines appear determines their order in the final message. These lines use the same syntax as heading definitions in the /etc/sendmail.cf configuration file.
I Specifies the i-number of the data file; this can be used to recover your mail queue after a disk crash.
K Specifies the time (as seconds) of the last delivery attempt.
M Contains a message printed by the mailq command. It is mainly used to store status information.
N Specifies the total number of delivery attempts.
O Specifies the original message transfer system (MTS) value from the Ethernet Simple Mail Transfer Protocol (SMTP) transaction. Used for Delivery Status Notifications only.
P Contains the priority of the current message. The priority is used to order the queue. Higher numbers mean lower priorities. The priority increases as the message sits in the queue. The initial priority depends on the message class and the size of the message.
Q Contains the original recipient as specified by the ORCPT= field in an SMTP transaction. Used exclusively for Delivery Status Notifications. It applies only to the immediately following “R” line.
R Contains a recipient address. There is one line for each recipient.
S Contains the sender address. There is only one of these lines.
T Contains the message creation time used to compute when to time out the message.
V Specifies the version number of the queue file format used to allow new sendmail binaries to read queue files created by older versions. Defaults to version zero. Must be the first line of the file, if present.
Z Specifies the original envelope ID (from the SMTP transaction). Used for Delivery Status Notifications only.
$ Contains a macro definition. The values of certain macros ($r and $s) are passed through to the queue run phase.
The q file for a message sent to amy@zeus would look similar to:
P217031 
T566755281 
MDeferred: Connection timed out during user open with zeus 
Sgeo 
Ramy@zeus 
H?P?return-path: <geo> 
Hreceived: by george (0.13 (NL support)/0.01) 
        id AA00269; Thu, 17 Dec 87 10:01:21 CST 
H?D?date: Thu, 17 Dec 87 10:01:21 CST 
H?F?From: geo 
Hmessage-id: <8712171601.AA00269@george> 
HTo: amy@zeus 
Hsubject: test
Where:
P217031 Priority of the message
T566755281 Submission time in seconds
MDeferred: Connection timed out during user open with zeus
Status message
Sgeo ID of the sender
Ramy@zeus ID of the receiver
HLines Header information for the message

This is a much more elaborate but harder to read part of the Sendmail Book (other copies did not turn op in the searches):

[Wayback/Archive] [Chapter 23] 23.9 The qf File Internals

23.9 The qf File Internals

The qf file holds all the information that is needed to perform delivery of a queued mail message. The information contained in that file, and its appearance, changes from release to release of sendmail. Here, we document the qf file that is used with V8.8 sendmail. Note that as of V8.7 a V version line has been introduced to enable future versions to correctly process older version’s queue files.

This section must be taken with a proverbial grain of salt. The internals of the qf file are essentially an internal interface to sendmail and, as such, are subject to change without notice. The information offered here is intended only to help debug sendmail problems. It is not intended (and we strongly discourage its use) as a guide for writing files directly to the queue.

The qf file is line-oriented, containing one item of information per line. Each line begins with a single uppercase character (the code letter), which specifies the contents of the line. Each code letter is followed, with no intervening space, by the information appropriate to the letter. The complete list of code letters is shown in Table 23.2.

Table 23.2: qf File Code Letters
Code Meaning Version How Many
B Section 23.9.1 Body type V8.6 and above At most one
C Section 23.9.2 Controlling user V5.62 and above At most one per R line
D Section 23.9.3, D line Data filename Obsolete as of V8.7 Exactly one
E Section 23.9.4, E line Errors to V8.6 and earlier Many
F Section 23.9.5, F line Flag bits V8.1 and above Many
H Section 23.9.6, H line Header definition All versions Many
I Section 23.9.8, K line df file’s inode number V8.7 and above Exactly one
K Section 23.9.8 Time last processed V8.7 and above Exactly one
M Section 23.9.9 Message (why queued) All versions At most one
N Section 23.9.10, N line Number times tried V8.7 and above At most one
P Section 23.9.11 Priority (current) All versions At most one
Q Section 23.9.12, Q line Original recipient V8.7 and above At most one per R line
R Section 23.9.13 Recipient address All versions Many
S Section 23.9.14 Sender address All versions Exactly one
T Section 23.9.15 Time created All versions Exactly one
V Section 23.9.16, V line Version V8.7 and above Exactly one
Z Section 23.9.17, Z line DSN envelope ID V8.7 and above At most one
$ Section 23.9.18, $ line Restore macro value V8.6 and above At most one each
. Section 23.9.19, . line End of qf file V8.7 and above At most one

Some code letters may appear only once in a qf file; others may appear many times. Any line that begins with a tab or space character is joined to the line above it. Empty lines are ignored. The order in which these lines appear in the qf file is important for the mailq command to work properly.

We discuss the individual lines in the qf file by code letters. Each letter is presented in alphabetical order rather than the order in which they should appear in the qf file.

From an earlier section is [Wayback/Archive] [Chapter 23] 23.2 Parts of a Queued Message:

23.2 Parts of a Queued Message

When a message is stored in the queue, it is split into pieces. Each of those pieces is stored as a separate file in the queue directory. That is, the header and other information about the message are stored in one file, while the body (the data) is stored in another. All told, six different types of files may appear in the queue directory. The type of each is denoted by the first two letters of the filenames. Each filename begins with a single letter followed by an f character. The complete list is shown in Table 23.1.

Table 23.1: Queue File Types
File Description
df Section 23.2.2, “The Data (Message Body) File: df” Data (message body)
lf Section 23.2.3, “The Lock File (obsolete as of V5.62): lf” Lock file (obsolete as of V5.62)
nf Section 23.2.4, “The ID Creation File (obsolete as of V5.62): nf” ID creation file (obsolete as of V5.62)
tf Section 23.2.6, “The Temporary qf Rewrite Image: tf” Temporary qf rewrite image
xf Section 23.2.7, “The Transcript File: xf” Transcript file
qf Section 23.2.5, “The Queue Control File: qf” Queue control file (and headers)

The complete form for each filename is

Xfident

The X is one of the leading letters shown in Table 23.1. The f is the constant letter f. The ident is a unique queue identifier associated with each mail message.

In the following sections we first describe the identifier that is common to all the queue file parts, then describe each file type in alphabetical order. The internal details of the qf file can vary depending on the version of sendmail, so it is discussed separately at the end of this chapter.

Via:

Related:

–jeroen

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.