Test the mail command in Linux

Source: Internet
Author: User
Test the mail command in Linux-Linux Enterprise Application-Linux server application information. For more information, see. Most people will try man first. Here we will post the results:

MAIL (1) BSD General Commands Manual MAIL (1)

NAME
Mail-send and receive mail

SYNOPSIS
Mail [-iInv] [-s subject] [-c cc-addr] [-B bcc-addr] to-addr... [? Sendmail-options…]
Mail [-iInNv]-f [name]
Mail [-iInNv] [-u user]

I am a Typical lazy and don't like to look at these messy parameters. I just want to solve the problem as quickly as possible.

I only use examples to talk about it:

1. The simplest example:

Mail-s test yangfang@fudan.edu.cn
The result of this command is to send an empty letter named test to the mailbox behind it. If you have an mta and the mailbox behind it won't block this strange message, you will be able to receive this letter. If you do not want to be disturbed by such a mess, use a local account for your mailbox.

2. Example 2:

Send emails in three common formats
Mail-s test yangfang@fudan.edu.cn # The first method, you can use the current shell as the editor, edit the content after Ctrl-D end
Echo "mail content" | mail-s test yangfang@fudan.edu.cn # the second method, I use the most, may be like the reason for Pipeline
Mail-s test yangfang@fudan.edu.cn <file # The third method, mail with file content as the mail content

In fact, you can easily find that mail reads the file content from the standard input and sends a mail. I just want to let you know this. Here, the second example ends.

3. In the third example, emails with attachments

If you do not have the uuencode command in your system, install sharutils (yum install sharutils) first)

Uuencode requires two parameters. The first one is the file you want to send (you). Of course, this can also be done using pipelines, and the second one is the file name displayed.

Uuencode/home/yfang/a.gif | mail-s pictest yangfang@fudan.edu.cn
Tar czf-/home/yfang/| uencode home. tgz | mail-s pictest yangfang@fudan.edu.cn

Ps: By the way, the mail in slackware seems to have a-a parameter. You can add attachments directly. I have never used it.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.