How to send mail via command line in linux
1. The simplest method:
Mail-s text ** @ mail.ustc.edu.cn
The result of this command is to send an empty email with the title text to the mailbox, but such emails are often treated as spam emails,
If you do not receive an email, we recommend that you open the recycle bin to check the information. The first method is to use the current shell as an editor,
After the content is edited, Ctrl-D.
2. Practical mail sending method.
# Method 2: Use the pipeline command
Echo "This is a test mail !" | Mail-s text ** @ mail.ustc.edu.cn
# Method 3: Use redirection.
Mail-s test ** @ mail.ustc.edu.cn <file
To send a mail with the file content, first select to write a document in advance and then mail it in the past.
3. Email sending with attachments (important)
If you do not have the uuencode command in your system, you need to install sharutils first,
Sudo apt-get install sharutils.
Uuencode requires two parameters. The first is the file you want to send. Of course, this can also be done using pipelines, and the second is the file name displayed.
Uuencode/home/daniel/httpd. conf httpd. conf | mail-s mailtest ** @ mail.ustc.edu.cn