我在发送邮件时遇到问题...我有一台运行Ubuntu 16.04的服务器,在该服务器上,我运行(使用pm2)一个node.js服务器。我要求时,该服务器必须向我发送电子邮件。效果很好,但随后我配置了iptables,现在nodejs服务器无法再发送邮件了。我这样配置iptables:
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp-data
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:smtp
ACCEPT icmp -- anywhere anywhere
Chain FORWARD (policy DROP)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN limit: avg 1/sec burst 5
ACCEPT udp -- anywhere anywhere limit: avg 1/sec burst 5
ACCEPT icmp -- anywhere anywhere icmp echo-request limit: avg 1/sec burst 5
ACCEPT tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/RST limit: avg 1/sec burst 5
Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp-data
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:smtp
ACCEPT tcp -- anywhere anywhere tcp dpt:ntp
ACCEPT icmp -- anywhere anywhere
当我接受所有输出(iptables -P OUTPUT ACCEPT
)时,邮件已正确发送,因此我认为问题出在输出链中,但找不到。我尝试了很多在Internet上找到的解决方案,但我的情况下没有任何一项工作。另外,我使用nodemailer发送邮件,并使用gmail作为服务。这是我的电子邮件配置:
module.exports = {
config: {
service: 'gmail',
secure: false,
auth: {
user: '[email protected]',
pass: '********'
},
tls: {
rejectUnauthorized: false
}
},
receiver: "[email protected]"
};
我希望有人在这一点上会比我更清楚...感谢您的阅读,并祝您愉快!
我有同样的问题...解决了吗?