linux下mail使用故障mail: command not found

 因为监控的需求,所以写了个简单的脚本将服务器上的信息发送到我的邮箱,脚本编写完后运行,首先出现:

  -bash: mail: command not found

  后来想起系统当初是最小化安装的,很多工具包都没有安装,接着发现sendmail也没有安装,于是就一并yum安装完事:

  yum -y install mailx sendmail

  等待安装完后,再次运行脚本,没有报错,但是邮件确没有发送出去,查看服务器mail日志发现:

  cat /var/log/maillog

  Dec 17 11:42:29 localhost sendmail[30528]: qBH3gT5P030528: [email protected], ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30138, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]

  出现这个错误的原因是/var/spool/mail这个目录的权限不够,需要设置成777

  chmod -R 777 /var/spool/mail

  然后重启sendmail服务

  service sendmail restart

  再次调用脚本,一起正常。

猜你喜欢

转载自blog.csdn.net/professorphp/article/details/76921207
今日推荐