我想通过 Centos7 中的命令发送电子邮件。我对此问题使用了"telnet"命令,如下所示:
I touch example.sh file and save these command inside it :
echo "open mail.test.com 25"
sleep 3
echo "mail from:sender@test.com"
echo "rcpt to:receiver@test.com"
echo "data"
echo "hello"
echo "."
sleep 3
并使用此命令./example.sh | telnet
但它不起作用
你能帮帮我吗 谢谢
telnet
是为交互式使用而设计的。使用netcat
、ncat
、nc
、socat
或该系列的任何其他工具。
例:
./example.sh | ncat mail.test.com 25
在此,您必须编辑脚本:
echo "mail from:sender@test.com"
echo "rcpt to:receiver@test.com"
echo "data"
echo "hello"
echo "."
sleep 3
最后一项sleep 3
很重要,ncat
有足够的时间来处理结果。
顺便说一句,我什么也没测试(只是写下来)