.TH "DOVEADM-FETCH" "1" "May 2026" "e5ac02a" "Dovecot"
.SH "NAME"
\fBdoveadm-fetch\fR - Fetch partial/full messages or message information
.SH "SYNOPSIS"
.P
\fBdoveadm\fR \[lB]\fIGLOBAL OPTIONS\fR\[rB] \[lB]\fB-f\fR \fIformatter\fR\[rB] \fBfetch\fR \[lB]\fB-S\fR \fIsocket_path\fR\[rB] \fB-A\fR \fIfields\fR \fIsearch_query\fR
.P
\fBdoveadm\fR \[lB]\fIGLOBAL OPTIONS\fR\[rB] \[lB]\fB-f\fR \fIformatter\fR\[rB] \fBfetch\fR \[lB]\fB-S\fR \fIsocket_path\fR\[rB] \fB-F\fR \fIfile\fR \fIfields\fR \fIsearch_query\fR
.P
\fBdoveadm\fR \[lB]\fIGLOBAL OPTIONS\fR\[rB] \[lB]\fB-f\fR \fIformatter\fR\[rB] \fBfetch\fR \[lB]\fB-S\fR \fIsocket_path\fR\[rB] \fB--no-userdb-lookup\fR \fIfields\fR \fIsearch_query\fR
.P
\fBdoveadm\fR \[lB]\fIGLOBAL OPTIONS\fR\[rB] \[lB]\fB-f\fR \fIformatter\fR\[rB] \fBfetch\fR \[lB]\fB-S\fR \fIsocket_path\fR\[rB] \fB-u\fR \fIuser\fR \fIfields\fR \fIsearch_query\fR
.SH "DESCRIPTION"
.P
\fBdoveadm fetch\fR can be used to fetch messages' contents and metadata. This can be useful for scripts and for debugging. If you want to fetch messages one at a time, see doveadm-search(1).
.RS 0
.IP \(bu 4
Please respect your users' privacy.
.RE 0

.SH "GLOBAL OPTIONS"
.P
Global doveadm(1) \fIoptions\fR:
.P
\fB-D\fR
.RS 0
.RS 4
.P
Enables \fIverbosity\fR and debug messages.
.RE 0

.RE 0

.P
\fB-O\fR
.RS 0
.RS 4
.P
Do not read any config file, just use defaults. The \fBdovecot_storage_version\fR setting defaults to the latest version, but can be overridden with \fB-o\fR.
.RE 0

.RE 0

.P
\fB-k\fR
.RS 0
.RS 4
.P
Preserve entire environment for doveadm, not just \fBimport_environment\fR setting.
.RE 0

.RE 0

.P
\fB-v\fR
.RS 0
.RS 4
.P
Enables verbosity, including progress counter.
.RE 0

.RE 0

.P
\fB-i\fR \fIinstance-name\fR
.RS 0
.RS 4
.P
If using multiple Dovecot instances, choose the config file based on this instance name.
.P
See \fBinstance_name\fR setting for more information.
.RE 0

.RE 0

.P
\fB-c\fR \fIconfig-file\fR
.RS 0
.RS 4
.P
Read configuration from the given \fIconfig-file\fR. By default it first reads config socket, and then falls back to \fI/etc/dovecot/dovecot.conf\fR. You can also point this to config socket of some instance running compatible version.
.RE 0

.RE 0

.P
\fB-o\fR \fIsetting\fR\fB=\fR\fIvalue\fR
.RS 0
.RS 4
.P
Overrides the configuration \fIsetting\fR from \fI/etc/dovecot/dovecot.conf\fR and from the userdb with the given \fIvalue\fR. In order to override multiple settings, the \fB-o\fR option may be specified multiple times.
.RE 0

.RE 0

.P
\fB-f\fR \fIformatter\fR
.RS 0
.RS 4
.P
Specifies the \fIformatter\fR for formatting the output. Supported formatters are:
.P
\fBflow\fR
.RS 4
.P
prints each line with \fIkey\fR\fB=\fR\fIvalue\fR pairs.
.RE 0

.P
\fBjson\fR
.RS 4
.P
prints a JSON array of JSON objects.
.RE 0

.P
\fBpager\fR
.RS 4
.P
prints each \fIkey\fR: \fIvalue\fR pair on its own line and separates records with form feed character (\fB^L\fR).
.RE 0

.P
\fBtab\fR
.RS 4
.P
prints a table header followed by tab separated value lines.
.RE 0

.P
\fBtable\fR
.RS 4
.P
prints a table header followed by adjusted value lines.
.RE 0

.RE 0

.RE 0

.P
This command uses by default the output formatter \fBpager\fR.
.SH "OPTIONS"
.P
\fB-A\fR
.RS 0
.RS 4
.P
If the \fB-A\fR option is present, the \fIcommand\fR will be performed for all users. Using this option in combination with system users from \fBuserdb { driver = passwd }\fR is not recommended, because it contains also users with a lower UID than the one configured with the \fBfirst_valid_uid\fR setting.
.P
When the SQL userdb module is used, make sure that the \fBuserdb_sql_iterate_query\fR setting setting matches your database layout.
.P
When using the LDAP userdb module, make sure that the \fBuserdb_fields\fR setting and \fBuserdb_ldap_iterate_fields\fR setting settings match your LDAP schema. Otherwise doveadm(1) will be unable to iterate over all users.
.RE 0

.RE 0

.P
\fB-F\fR \fIfile\fR
.RS 0
.RS 4
.P
Execute the \fIcommand\fR for all the users in the \fIfile\fR. This is similar to the \fB-A\fR option, but instead of getting the list of users from the userdb, they are read from the given \fIfile\fR. The \fIfile\fR contains one username per line.
.RE 0

.RE 0

.P
\fB--no-userdb-lookup\fR
.RS 0
.RS 4
.P
Do not perform userdb lookup. Use the \fBUSER\fR environment variable to specify the username.
.RE 0

.RE 0

.P
\fB-S\fR \fIsocket_path\fR
.RS 0
.RS 4
.P
The option's argument is either an absolute path to a local UNIX domain socket, or a hostname and port (\fIhostname\fR:\fIport\fR), in order to connect a remote host via a TCP socket.
.P
This allows an administrator to execute doveadm(1) mail commands through the given socket.
.RE 0

.RE 0

.P
\fB-u\fR \fIuser/mask\fR
.RS 0
.RS 4
.P
Run the \fIcommand\fR only for the given \fIuser\fR. It's also possible to use '\fB*\fR' and '\fB?\fR' wildcards (e.g. -u *@example.org).
.RE 0

.RE 0

.SH "ARGUMENTS"
.P
\fIfields\fR
.RS 0
.RS 4
.P
One or more result field names to display, if the \fIsearch_query\fR matches any messages. In order to specify multiple fields, enclose them in single or double quotes.
.P
Supported \fIfields\fR are:
.RS 4
.P
\fBbinary\fR : Message body in decoded format.
.RE 0

.RS 4
.P
\fBbinary.<section>\fR : Part of the body decoded, e.g. binary.1
.RE 0

.RS 4
.P
\fBbody\fR : The body of a message.
.RE 0

.RS 4
.P
\fBbody.<section>\fR : Part of the body, e.g. body.1
.RE 0

.RS 4
.P
\fBbody.preview\fR : Short preview of the body.
.RE 0

.RS 4
.P
\fBbody.snippet\fR : Old alias for preview.
.RE 0

.RS 4
.P
\fBdate.received\fR : Date and time of final delivery, when the message was delivered to a user's mailbox for the first time.
.P
The internal date and time of the source message, when the message was copied by the IMAP COPY command.
.P
The date-time attribute when present, otherwise the current time, when the message was saved by the IMAP APPEND command.
.RE 0

.RS 4
.P
\fBdate.received.unixtime\fR : date.received as unix timestamp.
.RE 0

.RS 4
.P
\fBdate.saved\fR : Date and time when the message was saved to mailbox.
.RE 0

.RS 4
.P
\fBdate.saved.unixtime\fR : date.saved as unix timestamp.
.RE 0

.RS 4
.P
\fBdate.sent\fR : Date and time of the message's Date: header.
.RE 0

.RS 4
.P
\fBdate.sent.unixtime\fR : date.sent as unix timestamp.
.RE 0

.RS 4
.P
\fBflags\fR : A message's IMAP flags, e.g. \[rs]Seen
.RE 0

.RS 4
.P
\fBguid\fR : A message's globally unique identifier.
.RE 0

.RS 4
.P
\fBhdr\fR : The header of the message.
.RE 0

.RS 4
.P
\fBhdr.<name>\fR : Named header from the message.
.RE 0

.RS 4
.P
\fBimap.body\fR : IMAP BODY output of the message (see RFC 3501).
.RE 0

.RS 4
.P
\fBimap.bodystructure\fR : IMAP BODYSTRUCTURE output of the message (see RFC 3501).
.RE 0

.RS 4
.P
\fBimap.envelope\fR : IMAP ENVELOPE output of the message (see RFC 3501).
.RE 0

.RS 4
.P
\fBmailbox\fR : Name of the mailbox, in which the message is stored. The name is in UTF-8.
.RE 0

.RS 4
.P
\fBmailbox-guid\fR : The globally unique identifier of the mailbox, in which the message is located.
.RE 0

.RS 4
.P
\fBmodseq\fR : Modification sequence number for the mail.
.RE 0

.RS 4
.P
\fBpop3.order\fR : A message's order number within a mailbox.
.RE 0

.RS 4
.P
\fBpop3.uidl\fR : A message's unique (POP3) identifier within a mailbox.
.RE 0

.RS 4
.P
\fBrefcount\fR : Mail reference count, mdbox only.
.RE 0

.RS 4
.P
\fBseq\fR : A message's sequence number in a mailbox.
.RE 0

.RS 4
.P
\fBsize.physical\fR : A message's physical size.
.RE 0

.RS 4
.P
\fBsize.virtual\fR : A message's virtual size, computed with CRLF line terminators.
.RE 0

.RS 4
.P
\fBstorageid\fR : Mailbox driver specific ID for the mail.
.RE 0

.RS 4
.P
\fBtext\fR : The entire message (header and body).
.RE 0

.RS 4
.P
\fBtext.utf8\fR : The entire message (header and body) \[em] UTF-8 encoded.
.RE 0

.RS 4
.P
\fBuid\fR : A message's unique (IMAP) identifier in a mailbox.
.RE 0

.RS 4
.P
\fBuser\fR : A message owner's login name.
.RE 0

.RE 0

.RE 0

.P
\fIsearch_query\fR
.RS 0
.RS 4
.P
Fetch messages matching this search query. See doveadm-search-query(1) for details.
.RE 0

.RE 0

.SH "EXAMPLE"
.P
This example based on the first example from doveadm-search(1). We are fetching the fields \fBmailbox\fR and \fBdate.sent\fR from user bob's mailbox with the guid "3a94c928d66ebe4bda04000015811c6a" for the messages with the UIDs \fB8\fR, \fB25\fR and \fB45\fR.
.P
.RS 2
.nf
doveadm fetch -u bob "mailbox date.sent" mailbox-guid 3a94c928d66ebe4bda04000015811c6a uid 8,25,45
.fi
.RE
.P
.RS 2
.nf
mailbox: dovecot/pigeonhole/2.0
date.sent: 2010-01-19 01:17:41 (+0100)
^L
mailbox: dovecot/pigeonhole/2.0
date.sent: 2010-01-28 09:38:49 (+0100)
^L
mailbox: dovecot/pigeonhole/2.0
date.sent: 2010-03-28 18:41:14 (+0200)
.fi
.RE
.SH "REPORTING BUGS"
.P
Report bugs, including \fIdoveconf -n\fR output, to the Dovecot Mailing List \fI\(ladovecot@dovecot.org\(ra\fR. Information about reporting bugs is available at: \fI\(lahttps://dovecot.org/bugreport.html\(ra\fR
.SH "SEE ALSO"
.P
doveadm(1)
