GNU Mailutils Manual (split by node):   Section:   Chapter:FastBack: Programs   Up: mail   FastForward: Libraries   Contents: Table of ContentsIndex: Function Index

3.5.1 Invoking mail

General usage of mail program is:

      mail [option...] [address...]

If [address...] part is present, mail switches to mail sending mode, otherwise it operates in mail reading mode.

Mail understands the following command line options:

-A file
--attach=file

Attach file to the composed message. The encoding, content type, and content description are controlled by the --encoding, --content-type, and --content-name options, correspondingly.

The option --attach=- instructs mail to read the file to be attached from the standard input. Interactive shell is disabled in this case.

--attach-fd=fd

Read attachment body from the file descriptor fd. The descriptor must be open for reading. This option is useful when calling mail from another program.

See the options --encoding, --content-type, --content-name, and --content-filename.

-a header:value
--append=header:value

Append the given header to the composed message.

--content-type=type

This options sets the content type to be used by all subsequent --attach options.

--content-filename=name

Set the ‘filename’ parameter in the ‘Content-Disposition’ header for the next --attach-fd option.

--content-name=text

Set the ‘name’ parameter (description) in the ‘Content-Type’ header for the next --attach or --attach-fd option.

-E command
--exec=command

Execute command before opening the mailbox. Any number of --exec options can be given. The commands will be executed after sourcing configuration files (see Mail Configuration Files), but before opening the mailbox.

-e
--exist

Return true if the mailbox contains some messages. Return false otherwise.

This is useful for writing shell scripts.

--encoding=enc

Sets content transfer encoding for use by the subsequent --attach options.

-F
--byname

Record outgoing messages in a file named after the first recipient. The name is the login-name portion of the address found first on the ‘To:’ line in the mail header.

-f
--file

Operate on the mailbox given by the first non-optional command line argument. If there is no such argument, read messages from the user’s mbox file. See Reading Mail, for more details about using this option.

-H
--headers

Print header summary to stdout and exit.

-i
--ignore

Ignore interrupts when composing the message.

-M
--mime
--no-mime

The --mime option instructs mail to compose MIME messages. It is equivalent for -E 'set mime', except that it is processed after all other options. The --no-mime disables the MIME compose mode, and is a shortcut for -E 'set nomime',

-N
--nosum

Do not display initial header summary.

-n
--norc

Do not read the system-wide mailrc file. See Mail Configuration Files.

-p
--print
--read

Print all mail to standard output. It is equivalent to issuing following commands after starting ‘mail -N’:

print *
quit

except that mail --print does not change status of the messages.

-q
--quit

Cause interrupts to terminate program.

-r address
--return-address=address

Sets the return email address for outgoing mail. See return-address.

--skip-empty-attachments
--no-skip-empty-attachments

Don’t create attachments that would have zero-size body. This option affects all attachments created by --attach and --attach-fd options appearing after it in the command line, as well as the body of the original message.

To cancel its effect, use the --no-skip-empty-attachments option.

-s subj
--subject=subj

Send a message with a Subject of subj. Valid only in sending mode.

-t
--to

Read recipients from the message header. Ignore addresses listed in the command line.

-u user
--user=user

Operate on user’s mailbox. This is equivalent to:

mail -f/spool_path/user

with spool_path being the full path to your mailspool directory
(/var/spool/mail or /var/mail on most systems).

The program also understands the common mailutils options (see Common Options.

GNU Mailutils Manual (split by node):   Section:   Chapter:FastBack: Programs   Up: mail   FastForward: Libraries   Contents: Table of ContentsIndex: Function Index