1.在公司服务器上
sudo apt-get install mailutils
这里安装时会有一些配置(有界面的)。我也不是很懂。就看着配置了一下。
之后就可以发送了。(发送给别人还是收不到)
xiaochongyong@sam-server:~/\u684c\u9762/xcyNote$ echo "test,hahah222" | mail -s "xcytest" xiaochongyong
xiaochongyong@sam-server:~/\u684c\u9762/xcyNote$ mail
"/var/mail/xiaochongyong": 1 message 1 new
>N 1 xiaochongyong \u4e00 12\u6708 4 10: 13/471 xcytest
Return-Path:
X-Original-To: xiaochongyong@sam-server
Delivered-To: xiaochongyong@sam-server
Received: by sam-server (Postfix, from userid 1011)
id 296B35E024E; Mon, 4 Dec 2017 10:12:41 +0800 (CST)
Subject: xcytest
To:
X-Mailer: mail (GNU Mailutils 2.99.98)
Message-Id: <20171204021241.296B35E024E@sam-server>
Date: Mon, 4 Dec 2017 10:12:41 +0800 (CST)
From: xiaochongyong@sam-server (xiaochongyong)
test,hahah222
No applicable message
quit
Saved 1 message in /home/xiaochongyong/mbox
Held 0 messages in /var/mail/xiaochongyong
xiaochongyong@sam-server:~/\u684c\u9762/xcyNote$
2.在我的虚拟机上
sudo apt-get install mailutils
安装时也没有配置。之后直接发送,结果报错了:
xcy@xcy-virtual-machine:~$ echo "hahah,test" | mail -s "test"
xiao_chongyong@163.commail: cannot send message: Process exited with a non-zero status
然后参考了:
http://mars914.iteye.com/blog/1470961接着安装了
sudo apt-get install sendmail
sudo apt-get install sendmail-cf
sudo apt-get install sharutils
然后发送:
xcy@xcy-virtual-machine:~$ echo "hahaha" | mail -s "testxcy"
474724048@qq.comxcy@xcy-virtual-machine:~$ echo "hahaha2" | mail -s "testxcy"
474724048@qq.comxcy@xcy-virtual-machine:~$ echo "hahaha2" | mail -s "testxcy" xcy
xcy@xcy-virtual-machine:~$
每次都运行特别久。看样子的报错了。在home目录报错了一个mbox文件,里面记录了一些信息。
xcy@xcy-virtual-machine:/etc/mail$ mail
"/var/mail/xcy": 3 messages 3 new
>N 1 Mail Delivery Subs 一 12月 4 09: 65/2297 Returned mail: see transc
N 2 Mail Delivery Subs 一 12月 4 10: 65/2297 Returned mail: see transc
N 3 xcy 一 12月 4 10: 15/607 testxcy
Return-Path:
Received: from localhost (localhost)
by xcy-virtual-machine (8.14.4/8.14.4/Debian-4.1ubuntu1) id vB41nPSx0083
15;
Mon, 4 Dec 2017 09:49:25 +0800
Date: Mon, 4 Dec 2017 09:49:25 +0800
From: Mail Delivery Subsystem
Message-Id: <201712040149.vB41nPSx008315@xcy-virtual-machine>
To:
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
boundary="vB41nPSx008315.1512352165/xcy-virtual-machine"
Subject: Returned mail: see transcript for details
Auto-Submitted: auto-generated (failure)
This is a MIME-encapsulated message
--vB41nPSx008315.1512352165/xcy-virtual-machine
The original message was received at Mon, 4 Dec 2017 09:48:22 +0800
from localhost [127.0.0.1]
----- The following addresses had permanent fatal errors -----
<
474724048@qq.com>
(reason: 550 Failed to connect remote host.)
----- Transcript of session follows -----
... while talking to mx3.qq.com.:
<<< 550 Failed to connect remote host.
... while talking to mx2.qq.com.:
<<< 550 Failed to connect remote host.
于是把机器重启了一下。就可以了
xcy@xcy-virtual-machine:/var/mail$ echo "
20171204tete" | mail -s "t
est2" xcy
xcy@xcy-virtual-machine:/var/mail$ mail
"/var/mail/xcy": 3 messages 1 new 2 unread
U 1 Mail Delivery Subs 一 12月 4 10: 68/2341 Returned mail: see transc
U 2 xcy 一 12月 4 10: 17/626 testxcy
>N 3 xcy 一 12月 4 10: 15/610 test2
Return-Path:
Received: from xcy-virtual-machine (localhost [127.0.0.1])
by xcy-virtual-machine (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id vB42Yuhw003098
for
Received: (from xcy@localhost)
by xcy-virtual-machine (8.14.4/8.14.4/Submit) id vB42YuqW003093;
Mon, 4 Dec 2017 10:34:56 +0800
Date: Mon, 4 Dec 2017 10:34:56 +0800
From: xcy
Message-Id: <201712040234.vB42YuqW003093@xcy-virtual-machine>
Subject:
test2To:
X-Mailer: mail (GNU Mailutils 2.99.98)
20171204teteNo applicable message
但是发送给别人还是无法收到。
来源: http://www.cnblogs.com/xcywt/p/8016227.html