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