LinuxCommandLibrary

xdg-email

Open an email composer with specified information

SYNOPSIS

xdg-email [OPTIONS] [TO_ADDRESS]

PARAMETERS

TO_ADDRESS
    The primary recipient(s) of the email. Can be a single email address or a comma-separated list of addresses.

--subject SUBJECT
    Specifies the subject line for the email.

--body BODY
    Specifies the main content or body of the email.

--cc CC_ADDRESSES
    Specifies Carbon Copy (CC) recipient(s). Can be a comma-separated list of addresses.

--bcc BCC_ADDRESSES
    Specifies Blind Carbon Copy (BCC) recipient(s). Can be a comma-separated list of addresses.

--attachment FILE
    Specifies a file to be attached to the email. This option can be used multiple times to attach multiple files.

--print-commands
    Prints the commands that would be executed to launch the email client, without actually executing them. Useful for debugging.

--version
    Displays the xdg-utils version information.

--help
    Shows the help message for xdg-email.

DESCRIPTION

xdg-email is a command-line tool that allows users to open their preferred email client (Mail User Agent) to compose a new email. It is a part of the xdg-utils package, which provides a set of desktop-independent utilities for common tasks across different Linux desktop environments (e.g., GNOME, KDE, XFCE).

The primary function of xdg-email is to abstract away the specifics of various desktop environments and their default mail handlers, simplifying the process of initiating email composition from scripts or other command-line applications. It can pre-fill various email fields such as the recipient (TO), subject, body content, Carbon Copy (CC) recipients, Blind Carbon Copy (BCC) recipients, and even attach multiple files. This makes it highly versatile for automated or script-driven email generation tasks, ensuring that the user's chosen email client is utilized consistently.

CAVEATS

xdg-email relies on a correctly configured desktop environment and default applications. If no default mail client is set, or if it's misconfigured, xdg-email may fail or open an unexpected application.

Different email clients may have varying levels of support for all parameters (e.g., some simpler clients might not fully handle attachments or all header fields).

It's important to note that xdg-email only launches the email client with pre-filled fields; it does not send the email directly. The user still needs to manually click 'Send' within the launched client.

DESKTOP INTEGRATION

xdg-email functions by consulting the MIME type database and the user's default application settings, which are typically managed by their desktop environment. It effectively finds the registered handler for mailto: URLs or message/rfc822 MIME types and launches it with the provided parameters. This ensures that the command uses the same email client that would be launched if a user clicked a mailto: link in a web browser or another application.

RETURN STATUS

xdg-email exits with a status code of 0 on successful execution. A non-zero status code indicates a failure. Common non-zero exit codes include 1 (general error), 2 (command line syntax error), 3 (no default application found or configured), or 4 (the requested action failed to execute).

HISTORY

xdg-email is part of the xdg-utils project, initiated by freedesktop.org. The project's goal was to provide a set of command-line tools that work consistently across different Linux and Unix-like desktop environments (GNOME, KDE, XFCE, LXDE, etc.). This effort aimed to abstract away desktop-specific mechanisms for common tasks, ensuring that scripts and applications behave predictably regardless of the user's chosen desktop environment.

Its adoption reflects the success of the XDG Base Directory Specification and related initiatives in standardizing core desktop behaviors, providing a unified way to interact with user applications for tasks like opening files, browsing URLs, and, in the case of xdg-email, composing emails.

SEE ALSO

xdg-open(1), xdg-mime(1), mail(1), mutt(1)

Copied to clipboard