系统环境cengos6.2,需要装expect
脚本如下:
#!/usr/bin/expect
set smtp smtp.qq.com
set user ******* #**代表QQ号吗经过base64加密过的值
set pass ******* #**代表密码经过base64加密过的值
set from 986870231@qq.com
set to 986870231@qq.com
set title think
set content fuck
spawn telnet $smtp 25
expect "220"
send "helo root\r"
expect "250"
send "auth login\r"
expect "334"
send "$user\r"
expect "334"
send "$pass\r"
expect "235"
send "MAIL FROM: <$from>\r"
expect "250"
send "RCPT TO: <$to>\r"
expect "250"
send "DATA\r"
expect "354"
send "TO: $to\r"
send "FROM: $from\r"
send "SUBJECT: $title\r"
send "\r"
send "$content\r"
send ".\r"
expect "250"
send "QUIT"