# 创建脚本
cat > /usr/local/bin/block-smtp.sh << 'EOF'
#!/bin/bash
iptables -I OUTPUT -p tcp --dport 25 -j DROP
iptables -I OUTPUT -p tcp --dport 465 -j DROP
iptables -I OUTPUT -p tcp --dport 587 -j DROP
EOF

chmod +x /usr/local/bin/block-smtp.sh

# 创建 systemd 服务
cat > /etc/systemd/system/block-smtp.service << 'EOF'
[Unit]
Description=Block SMTP Ports
After=network.target docker.service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/block-smtp.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF

# 启用
systemctl daemon-reload
systemctl enable --now block-smtp.service
