一、telnet模拟发邮件
[root@sc_10_9_21_24_ucloud_jump ~]# telnet mx3.qq.com 25
Trying 58.251.110.111...
Connected to mx3.qq.com.
Escape character is '^]'.
220 newxmmxszb75.qq.com MX QQ Mail Server.
helo abc.cn
250-newxmmxszb75.qq.com-100.65.28.199-44465081
250-SIZE 73400320
250 OK
mail from:<x@abc.cn>
250 OK.
rcpt to:<448252153@qq.com>
250 OK 1
data
354 End data with <CR><LF>.<CR><LF>.
wo de
.
250 Ok: queued as
quit
221 Bye.
二、基于expect 脚本实现
j(1)expect环境安装:https://www.cnblogs.com/operationhome/p/9154055.html
(2) vim expect_sendmail.ex
#!/usr/bin/expect
set smtp_server mx3.qq.com
set smtp_port 25
set sender x@abc.cn
set to 448252153@qq.com
spawn telnet $smtp_server $smtp_port
expect "220"
send "helo abc.cn\r"
expect "250"
send "mail from:<$sender>\r"
expect "250"
send "rcpt to:<$to>\r"
expect "250"
send "data\r"
expect "354"
send "subject:来自xjm\r"
send "\r"
send "这是个测试邮件\r"
send ".\r"
expect "250"
send "quit\r"
(3) 执行
chmod 755 expect_sendmail.ex
./expect_sendmail.ex
https://web.sendcloud.net