Linux Mail command

Source: Internet
Author: User

Address: http://blog.sina.com.cn/s/blog_6a1837e90100prpy.html

 

To use the most common mail function in Ubuntu, you must install mailutils. Run the following command to install sudo apt-Get install mailutils: sudo apt-Get install sharutils;

The RedHat installation method is yum install sharutils.

Start the sendmail service in RedHat:/etc/init. d/sendmail start

This article mainly describes how to use the Linux Mail command and explains how to use the Linux Mail command through some simple applications. Linux Mail is not only a command, but also an email program, however, there should be very few people reading emails using mail! For system administrators, mail is very useful because managers can use mail to write scripts and send memos to system users on a regular basis.

Linux Mail command parameters:
I ignore tty interrupt signals. (Interrupt)
I forced the interaction mode. (Interactive)
V prints a message, such as the location and status of the mail. (Verbose)
N does not read the mail. RC configuration file.
S mail title.
C CC email address.
B. bcc email address.

All emails received by the system are saved in the "/var/spool/mail/[Linux User Name]" file.Enter mail in Linux, And the inbox is displayed.

At this time, the command prompt is "&": (you can enter the following command to perform relevant operations on the mail)
Unread mark as unread mail

H | headers: displays the current mail list

L | List displays the list of currently supported commands

? | HELP command parameter usage for displaying multiple mail lists

D. Delete the current email, and move the pointer down. D 1-100 Delete 1st to 100 emails

F | from only displays the simple information of the current email. F num: displays the simple information of an email.

F | from num pointer to an email

Z displays the last 20 emails in the inbox.

More | p | when reading the email content of the current pointer on the page, press the Space key to flip the page, and press the Enter key to move down a row

T | type | more | p | PAGE num read an email

N | next | {do not fill in anything} when reading the content of the next email containing the current pointer, press the Space key to flip the page, and press the Enter key to move down a line

V | visual current mail enters the plain text editing mode

N | next | {do not fill in anything} num reads an email

Top displays the mail header of the email with the current pointer

File | Folder: displays the file of the system email and the total number of emails.

Exit the MAIL command platform and do not save the previous operations, such as deleting emails.

Q: log out of the mail command platform and save the previous operations. For example, if you delete an email that has been deleted by D, the read email will be transferred to the mbox file in the current user's home directory. If you delete a file in mbox, it will be permanently deleted. On the Linux text command platform, enter mail-F mbox to view the emails in the mbox in the current directory.

CD changes the location of the current folder

When writing a letter, press Ctrl + C twice to stop working.

Press Ctrl + c once to exit reading.

Use the Linux Mail command to send an email:

1. Send the file as an email

Echo "email body" | mail-s Email Subject username @ address

2. Send the file as an email
Syntax: Mail-s "topic" username @ address <File
For example:
Mail-s "program" User <file. C: file. c

Send the mail content to the user with the topic program.

3. Send an email to the user of the system.
Syntax: Mail User Name

4. send an email to a foreign user
Syntax: Mail username @ accept address
... /Usr/lib/sendmail-BP
...... "Mail queue is empty "...... Mail ....

For example:
Mail test@hotmail.com
Subject: Mail Test
:
Enter Text Content
::
Press Ctrl + D or. to end the text.
Press Ctrl + C twice to interrupt the work. Do not send this letter.
CC (carbon copy): copy the text to another recipient.

5. Send the email to one or more email addresses.

Because no other options are added, the user must enter the title and the content of the letter. If user2 does not have a host location, it is sent to the user2 user on the email server.
Mail user1@email.address
Mail user1@email.address user2
Send mail.txt content to user2 and CC to user1. If you set this line of command to cronjob, You can regularly send the memorandum to the System user.
Mail-s title-C user1 user2 <mail.txt

6. Check whether the sent email is sent or stuck on the email server.
Syntax:/usr/lib/sendmail-BP
If "mail queue is empty" is displayed on the screen, mail has been sent.
Other error messages indicate that the email has not been sent for any reason.

 

View mail commands in Linux

14:45:32 | category:

Default category | Tag:
| Font size
Subscription

The system provides an email system for communication between users. When a user opens a terminal to register and log on, the system displays the following information:
You have mail.
In this case, you can enter the MAIL command to read the mail:
$ Mail
The mail program displays users' emails one by one, and displays the latest emails in chronological order. Emails are asked every time a letter is displayed.
Whether the user wants to process the letter. If the user answers D, the email is deleted. If you press the Enter key, the email is not modified.
(The letter is still saved and can be read again next time); if you answer P, you need to repeat the letter; s filename indicates you want to put the letter
Store the named file. If you answer Q, it means you want to exit from mail.

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.