During your stint as a Linux administrator, you’ll likely want to send mail from the server you are working on. Whether its sending a quick test message or emailing yourself a file, it can be done quickly and easily.

First of all, you might have to install the mail program to be able to send emails from your server.

For example, I installed this on Ubuntu with:

sudo apt-get install mailutils

The following command is a very simple way to send an email from the command line. The email body is echoed and piped to the mail program. The subject and addressee are arguments to the mail program.

echo "This is the message." | mail -s "This is the subject" user@domain.com

If you want to send a more detailed message, you can type the message in a file and send it like this:

mail -s "This is the subject" user@domain.com < email-file.txt

You can use the following command to attach a file to your message. The -A argument specifies the attachment. This is handy for sending a file to yourself so you can easily get it on another machine.

echo "This is a message with an attachment." | mail -s "This is the subject" -A image.jpg user@domain.com

That’s all you have to do to send a quick email from the command line!

  • What is your reaction?
  • 1 Votes
  • powered by Verysign
  • 100% like gnulinux.ro
  • unmoved gnulinux.ro
  • amused gnulinux.ro
  • excited gnulinux.ro
  • angry gnulinux.ro
  • sad gnulinux.ro
Chriss                   gnulinux.ro
chriss@system ~ $ hwinfo --short
48 articole
In context

  • Comment
  • powered by Verysign

Nici un comentariu inca. Fii primul!