Sendmail command in linux

The sendmail command in Linux is used to send emails from the command line. Here are some basic usage examples:

Basic Syntax:

sendmail [options] [email protected]

Options:

Examples:

  1. Send a simple email:

    echo "Hello, world!" | sendmail [email protected]

    This will send an email with the subject "Hello, world!" and the body "Hello, world!" to the [email protected].

  2. Send an email with a specific sender:

    sendmail -f [email protected] [email protected]

    This will send an email from the [email protected] to the [email protected].

  3. Send an email with a specific subject:

    echo "Hello, world!" | sendmail -t -s "Hello, world!" [email protected]

    This will send an email with the subject "Hello, world!" and the body "Hello, world!" to the [email protected].

  4. Send an email with attachments:

    sendmail -t -a /path/to/attachment [email protected]

    This will send an email with the attachment /path/to/attachment to the [email protected].

Note: The sendmail command is usually configured to use the system's default email settings, such as the sender's email address and the email server. If you want to use a specific email server, you may need to configure the sendmail command or use a different email client.

Alternative: If you want to send emails from the command line, you can also use other tools like mail or mutt.