安装sendmail
执行:
[root@vps478753 ~]# yum -y install sendmail
程序会自动搜索出sendmail安装程序自动安装。
安装好sendmail以后执行以下命令启动sendmail
[root@vps478753 ~]# service sendmail start
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
启动以后我们可以执行mail命令测试一下是否能发送邮件
一、通过文件内容发送邮件
首先创建一个body.txt
[root@vps478753 ~]# touch body.txt
写入内容
[root@vps478753 ~]# echo 'This is test mail'>body.txt
发送邮件
[root@vps478753 ~]# mail -s 'Test mail' [email protected] < body.txt不一会就收到邮件了
点击打开,正文内容就是body.txt的内容
This is test mail
二、使用管道符直接发送邮件内容
如果不想通过文件发送邮件内容也可以这么发送
[root@vps478753 ~]# echo "This is test mail" | mail -s 'Test mail' [email protected]
以上效果同文件发送邮件内容一样
如果提示mail: command not found
[root@vps478753 ~]# mail -s 'Test mail' [email protected] < body.txt
-bash: mail: command not found
那么就是没有安装mail命令,此时需要安装mail命令
[root@vps478753 ~]# yum install mailx -y
然后再重新发送以下邮件就好了!
特别注意,如果安装了防火墙,请添加如下规则:
iptables设定
# iptables -A INPUT -p tcp –dport 25 -j ACCEPT
# iptables -A INPUT -p udp –dport 25 -j ACCEPT
TPLink TLWDR4320 无线路由器IP带宽控制功能分配带宽设置方法
SQL Server 2008及更高版本数据库恢复做法之日志尾部备份实用指南
TPLink TLWDR4320 无线路由器控制管控小孩上网行为设置
TPLink TLWDR4320 无线路由器打印服务器设置指南
TPLink TLWDR8620 52 无线路由器当作交换机使用教程
TPLink TLWDR8620 52 无线路由器映射服务器到外网操作方法