send email from shell command line

1. Send an email through one command line.
[code language=”shell”]
echo "hello" | sendmail -f from@gmail.com -t to@yahoo.com.com
[/code]

2. Send an email through command line.
[code language=”shell”]
sendmail -t to@gmail.com,to@yahoo.com
[/code]
After the above command, enther these 3 lines and then press Ctrl-d
[code language=”text”]
From:from@outlook.com
Subject:test sendmail
This is an email sent through the sendmail command
[/code]

3. The content of the email is in the mail.txt which has the from, subject and message.
[code language=”text”]
From: peng.ye@bookspan.com
Subject: test sendmail
This is a test email using sendmail
[/code]
The above email content can be sent by this command on the command line.
[code language=”shell”]
sendmail -t to@gmail.com < mail.txt
[/code]

4. Send an email with attachement. The command line tool uuencode needs to be installed to use sendmail to send an email with attachment.
[code language=”shell”]
uuencode attachment.txt attachment.txt | sendmail -f from@gmail.com -t to@outlook.com,to@yahoo.com
[/code]

Search within Codexpedia

Custom Search

Search the entire web

Custom Search