前言
Linux--mail邮件命令
/var/spool/mail/root 中有新邮件 这个问题应该是网络混乱状态 还有就是root给管理员账户发送的报错。
报错如下:
1 命令说明
指令名称:mail
指令所在路径:/bin/mail
执行权限:所有用户
语法:mail [用户名] 此处的用户无论当前是否在线都可以
功能描述:查看发送电子邮件
范例:#mail root
1.2 应用举例
1.2.1 给root用户发送邮件
命令演示:
[root@localhost~]# mail root
Subject:the application of mail
today, I want tolearn the command of mail
It seems not sodifficult !
根据提示输入邮件标题和内容,按Ctrl+c键保存结束。
操作示意图如图1所示:
图1 给root用户发送邮件
需要说明的是:mail命令的执行利用的并不是目前我们已经搭建好的邮件服务器。即:如果是本机用户给本机用户发送邮件,利用的就是本地的内存。也就是说当前的linux系统并没有搭建邮件服务器,甚至是网络都不通,也能通过mail命令发送邮件。当前如果是要给真正的互联网邮箱发送邮件,那么就必须要求网络畅通了
1.2.2 root用户接收和查看邮件内容
命令演示:
[root@localhost~]# mail
Heirloom Mailversion 12.4 7/29/08. Type ? for help.
"/var/spool/mail/root":1 message 1 new
>N 1 root Sat Jul 30 05:49 19/685 "the application of mail"
&
操作示意图如图2所示:
图2 接收和查看邮件内容
邮件内容信息说明:
N:New,表示该邮件是新邮件,还未读。若该邮件已读,则该位置的N字母将不会再显示。
1:表示邮件序号。(此处表示第一封邮件)
root:表示邮件的发送发
Sat Jul 30 05:49:邮件发送日期和时间
"theapplication of mail":邮件的主题
"theapplication of mail":邮件保存的邮箱具体位置。
1.2.3 邮件交互界面可进行的操作
在“&”输入提示符后面输入help命令,查看该界面支持的相关命令。
& help
mail commands
type type messages
next goto and type nextmessage
from give head lines ofmessages
headers print out activemessage headers
deletedeletemessages
undeleteundeletemessages
save folder append messages tofolder and mark as saved
copy folder append messages tofolder without marking them
writefile appendmessage texts to file, save attachments
preservekeepincoming messages in mailbox even if saved
Replyreply to message senders
replyreply tomessage senders and all recipients
mailaddresses mail tospecific recipients
file folder change to another folder
quit quit and applychanges to folder
xit quit and discardchanges made to folder
! shell escape
cdchdirto directory or home if none given
list list names of allavailable commands
A consists of integers, ranges of same, or other criteria
separated byspaces. If omitted, mail uses the lastmessage typed.
操作示意图如图3所示:
图3 help命令查看邮件交互界面支持的相关命令
在该交互界面直接输入邮件序列号,就可以查看指定邮件的具体内容:
& 1
Message 1:
Fromroot@localhost.localdomain Sat Jul 3005:49:18 2016
Return-Path:
X-Original-To:root
Delivered-To:root@localhost.localdomain
Date: Sat, 30Jul 2016 05:49:17 +0800
To:root@localhost.localdomain
Subject: theapplication of mail
User-Agent:Heirloom mailx 12.4 7/29/08
Content-Type:text/plain; charset=us-ascii
From:root@localhost.localdomain (root)
Status: R
today, I want tolearn the command of mail
It seems not sodifficult !
操作结果示意图如图4所示:
图4 查看指定邮件的具体内容
此时若想回到之前的邮件显示列表,可在该交互界面输入字符“h”,操作结果显示如图5所示:
图5 返回邮件显示列表
如果想要删除邮件,可在该交互界面输入命令:d 邮件序号
若要退出当前交互界面,按q键即可。
操作结果示意图如图6所示:
图6 删除邮件操作
注意:mail命令的关键作用在于方便root用户及时查看系统信息邮件。
有时候系统会给root用户发送一些系统信息邮件。所以当我们root登录系统之后,系统就会提示有新的邮件,需要接收。
系统给root用户发送的邮件信息都是非常重要的。比如说日志的统计信息,还有一些系统的报错信息。所以,当收到root的邮件信息提示时,一定要及时仔细查看,因为很有可能系统在运行的过程中出现了一些问题了,有可能会影响到系统的稳定和安全。