deliver Command in Linux



The Linux deliver command delivers email to an IMAP mailbox. The Internet Message Access Protocol (IMAP) is a widely used email management protocol. On the other hand, an IMAP mailbox is a mail storage system that stores the emails on a server.

Note that the deliver command is less common and not the standard command in most Linux distributions.

Table of Contents

Here is a comprehensive guide to the options available with the deliver command −

Syntax of Deliver Command

The general syntax of the Linux deliver command is as follows −

deliver [options] 

The [options] field is used to specify the options such as specifying the configuration file or setting the return path.

deliver Command Options

The options used with the Linux deliver command are listed below −

Options Description
-C config_file To specify the custom configuration file to read options
-d To ignore the compatibility with the mail (bin/mail) command
-r To specify the return path (email address)
-f Equivalent to -r; to specify the return path (email address)
-m mailbox To specify the mailbox to deliver a message to (if userid is specified the message will be delivered to mail.userid.mailbox)
-a auth_id To specify the authorization ID of the sender (default ID is anonymous if not specified)
-q To force a message to deliver even the mailbox is over-quota
-l To accept and deliver messages through LMTP

Examples of deliver Command in Linux

This section will demonstrate the usage of the Linux deliver command through various examples −

  • Delivering Mail to a Specific Mailbox
  • Delivering Mail to a Specific Mailbox with Return Path
  • Delivering Mail to a Specific Mailbox even Mailbox is Over Quota
  • Displaying Help
  • Managing 8-bit Characters

Delivering Mail to a Specific Mailbox

To deliver a message to a specific mailbox, use the -m option with the username.

echo "A Test Mail" | deliver -C /etc/imapd.conf -m my_mailbox user

Here, the configuration options are taken from the default configuration file (imapd.conf), but a custom configuration can also be specified. The -m option is used to specify the mailbox name.

Delivering Mail to a Specific Mailbox with Return Path

The return path is an email address to receive bounce messages, or error notifications if mail fails to deliver. To specify the return path, the -r option is used −

echo "A Test Mail" | deliver -r [email protected] -m my_mailbox user

Delivering Mail to a Specific Mailbox even Mailbox is Over Quota

If the mail allocated space is full, it means the mailbox is over quota. To deliver a message in such case, the -q option is used −

echo "A Test Mail" | deliver -C /etc/imapd.conf -q -m my_mailbox user

Displaying Help

To display help related to the deliver command, use the man command. The man command is used to display the commands manual page.

man deliver
Displaying Help deliver Command

Managing 8-bit Characters

The 8-bit characters in the message depend upon two settings, reject8bit and munge8bit. If the reject8bit option is set to yes in the configuration file then the 8-bit characters will not be processed. If it is set to no, then 8-bit characters processing depends upon the munge8bit settings.

If the munge8bit setting is set to yes, then 8-bit characters will be replaced with X, if it is set to no, then 8-bit characters will remain untouched.

Managing 8-bit Characters deliver Command

By default, these settings are commented out in the configuration file. Uncomment these options before modifying them.

Delivering Mail through mail Command

The mail command is a highly recommended utility that sends email from standard input. To use it, it needs to be installed on Linux.

To install mail utility on Ubuntu, Debian, and Debian-based distros, use −

sudo apt install mailutils

To install it on RHEL and CentOS, use −

sudo yum install mailx

To send email using the mail command, use −

echo "A Test Mail" | mail -s "Test Mail" [email protected]

Conclusion

The deliver command in Linux delivers messages to the IMAP server. It typically uses the /etc/imapd.conf file for configuration, but it can also read the custom configuration file using the -C option.

There are many alternatives to the deliver command such as mail, which is a part of the mailutils package. Additionally, sendmail and mailx commands can be used to send email through the terminal.

In this tutorial, we explained the deliver command, its syntax, options, and usage through examples.

Advertisements