How to send mail with sendmail

Sendmail is a popular open-source mail transfer agent (MTA) that allows you to send and receive emails on a Linux or Unix-based system. Here's a step-by-step guide on how to send mail using sendmail:

Prerequisites:

  1. Sendmail must be installed and configured on your system.
  2. You need to have a valid email address and a mail server (SMTP) to send the email.

Sending an email using sendmail:

  1. Open a terminal or command prompt on your system.
  2. Use the following command to send an email:
    sendmail -v -t <recipient_email_address>

    Replace <recipient_email_address> with the actual email address of the recipient.

The -v option enables verbose mode, which displays the email headers and body. The -t option tells sendmail to read the email message from standard input.

  1. Type the email message, including the subject and body, and press Enter. The message will be sent to the recipient.

Example:

sendmail -v -t [email protected]
To: [email protected]
Subject: Test email from sendmail

This is a test email sent using sendmail.
  1. Press Enter to send the email.

Sending an email with attachments:

To send an email with attachments, you can use the -i option to specify the attachment file. For example:

sendmail -v -t -i attachment.txt [email protected]

This will send the email with the attachment file attachment.txt.

Sending an email with a specific sender:

To send an email with a specific sender, you can use the -f option to specify the sender's email address. For example:

sendmail -v -t -f [email protected] [email protected]

This will send the email with the sender's email address set to [email protected].

Tips and Variations:

Remember to replace <recipient_email_address> with the actual email address of the recipient, and adjust the options and arguments according to your specific needs.