How to send mail using sendmail in unix

Sendmail is a popular mail transfer agent (MTA) used in Unix-like operating systems to send and receive emails. Here's a step-by-step guide on how to send mail using sendmail in Unix:

Prerequisites:

  1. Make sure you have sendmail installed on your system. You can check by running the command sendmail -v (with the -v option for verbose mode).
  2. You need to have a valid email address and a mail server configured on your system.

Sending a mail using sendmail:

  1. Open a terminal and navigate to the directory where you want to send the mail from.
  2. Use the sendmail command followed by the recipient's email address and the subject of the mail. For example:
    sendmail -v [email protected] "Subject: This is a test mail"

    Replace [email protected] with the actual email address of the recipient, and Subject: This is a test mail with the subject of the mail.

Options:

You can use various options with the sendmail command to customize the mail. Here are some common options:

For example, to send a mail with a attachment, you can use the following command:

sendmail -v -t -f [email protected] -s "Subject: This is a test mail" -a attachment.txt [email protected]

Replace [email protected] with your email address, attachment.txt with the name of the attachment file, and [email protected] with the recipient's email address.

Tips: