linux wifi数据发送邮件,Linux中无法发送邮件

## Linux中无法发送邮件

>[success]出现这种情况,一般是因为服务器上设置了防火墙。

在这里,默认使用如下防火墙设置

~~~

#!/bin/bash

#配置服务器防火墙

#author yifeng (E-mail:576617109@qq.com)

iptables -F #先清空规则

iptables -P INPUT DROP #禁止所有访问

iptables -P OUTPUT DROP #禁止所有响应

iptables -P FORWARD DROP #禁止所有转发

iptables -A INPUT -p tcp --dport 80 -j ACCEPT #允许web访问

iptables -A INPUT -p tcp --dport 22 -j ACCEPT #允许ssh访问

iptables -A INPUT -p icmp -j ACCEPT #开启ping

iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT #响应web访问

iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT #响应ssh访问

iptables -A OUTPUT -p icmp -j ACCEPT #响应ping 访问

~~~

按如上方式配置后,执行下面语句进行邮件发送:

~~~

echo '测试'|mailx -s "易风课堂" 576617109@qq.com

~~~

出现如下提示:

![](https://box.kancloud.cn/55784400747dce514335c71897e9711a_1102x135.png)

根据提示可以知道是没有办法,正确的解析smtp.163.com,这里是因为53端口没有开。

执行如下语句开启53端口

~~~

iptables -A INPUT -p tcp --dport 53 -j ACCEPT

iptables -A OUTPUT -p tcp --sport 53 -j ACCEPT

iptables -A INPUT -p tcp --sport 53 -j ACCEPT

iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT

iptables -A INPUT -p UDP --dport 53 -j ACCEPT

iptables -A OUTPUT -p UDP --sport 53 -j ACCEPT

iptables -A INPUT -p UDP --sport 53 -j ACCEPT

iptables -A OUTPUT -p UDP --dport 53 -j ACCEPT

~~~

然后,继续执行邮件发送:

~~~

echo '测试'|mailx -s "易风课堂" 576617109@qq.com

~~~

出现如下提示:

![](https://box.kancloud.cn/b0025e0b2ddf576d1abd2b60bac7744d_1102x153.png)

出现以上提示,是因为25端口没有开,所以没有办法以进行通信。

执行如下命令,开启25端口:

~~~

#! /bin/bash

iptables -A INPUT -p tcp --dport 25 -j ACCEPT

iptables -A OUTPUT -p tcp --sport 25 -j ACCEPT

iptables -A INPUT -p tcp --sport 25 -j ACCEPT

iptables -A OUTPUT -p tcp --dport 25 -j ACCEPT

iptables -A INPUT -p udp --dport 25 -j ACCEPT

iptables -A OUTPUT -p udp --sport 25 -j ACCEPT

iptables -A INPUT -p udp --sport 25 -j ACCEPT

iptables -A OUTPUT -p udp --dport 25 -j ACCEPT

~~~

开启25端口之后,即可以正常发送邮件了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值