send email from shell command line
1. Send an email through one command line.
echo "hello" | sendmail -f email@example.com -t firstname.lastname@example.org
2. Send an email through command line.
sendmail -t email@example.com,firstname.lastname@example.org
After the above command, enther these 3 lines and then press Ctrl-d
From:email@example.com 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.
From: firstname.lastname@example.org 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 email@example.com < 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 firstname.lastname@example.org -t email@example.com,firstname.lastname@example.org
Search within Codexpedia
Search the entire web