send email from shell command line

1. Send an email through one command line.

echo "hello" | sendmail -f -t

2. Send an email through command line.

sendmail -t,

After the above command, enther these 3 lines and then press Ctrl-d
Subject:test sendmail
This is an email sent through the sendmail command     

3. The content of the email is in the mail.txt which has the from, subject and message.

Subject: test sendmail
This is a test email using sendmail

The above email content can be sent by this command on the command line.

sendmail -t < mail.txt

4. Send an email with attachement. The command line tool uuencode needs to be installed to use sendmail to send an email with attachment.

uuencode attachment.txt attachment.txt | sendmail -f -t,

Search within Codexpedia

Custom Search

Search the entire web

Custom Search