CentOS 是一个非常不错的免费开源 Linux 系统,许多站点首选的平台。然而 CentOS 预设不能传送邮件,需要传送邮件的童鞋可以安装一个 sendmail 程式。
安装 sendmail
执行:
1
[root@vps478753 ~]# yum -y install sendmail
程式会自动搜寻出 sendmail 安装程式自动安装。
安装好 sendmail 以后执行以下命令启动 sendmail
1
2
3
[root@vps478753 ~]# service sendmail start
Starting sendmail:                                         [  OK  ]
Starting sm-client:                                        [  OK  ]
启动以后我们可以执行 mail 命令测试一下是否能传送邮件
一、通过档案内容传送邮件
首先建立一个 body.txt
1
[root@vps478753 ~]# touch body.txt
写入内容
1
[root@vps478753 ~]# echo ‘This is test mail’>body.txt
传送邮件
1
[root@vps478753 ~]# mail -s ‘Test mail’ mail@lizhong.me < body.txt 不一会就收到邮件了 CentOS 安装 mail 命令 点选开启,正文内容就是 body.txt 的内容 This is test mail 二、使用管道符直接传送邮件内容 如果不想通过档案传送邮件内容也可以这么传送 1 [root@vps478753 ~]# echo “This is test mail” | mail -s ‘Test mail’ mail@lizhong.me 以上效果同档案传送邮件内容一样 如果提示 mail: command not found 1 2 [root@vps478753 ~]# mail -s ‘Test mail’ mail@lizhong.me < body.txt -bash: mail: command not found 那么就是没有安装 mail 命令,此时需要安装 mail 命令 1 [root@vps478753 ~]# yum install mailx -y 然后再重新传送以下邮件就好了!