telnet 自動發郵件的腳本

telnet 自動發送郵件
$ chmod a+x aa.ex
$ ./aa.ex stmp.163.com base64之後的用戶名 base64之後的密碼 frommail tomail title content
aa.ex腳本如下:
#!/usr/bin/expect
set smtp    [lindex $argv 0]
set user    [lindex $argv 1]
set pass    [lindex $argv 2]
set from    [lindex $argv 3]
set to      [lindex $argv 4]
set title   [lindex $argv 5]
set content [lindex $argv 6]
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"
 
 
 
測試通過的腳本
telnet.sh 220.181.15.139 [email protected] [email protected] nihao test
[root@soft fjiang]# more telnet.sh
#!/usr/bin/expect
set smtp    [lindex $argv 0]
set from    [lindex $argv 1]
set to      [lindex $argv 2]
set title   [lindex $argv 3]
set content [lindex $argv 4]
spawn telnet $smtp 25
expect "220"
send "HELO xinhua.org\r"
expect "250 OK"
send "MAIL FROM: <$from>\r"
expect "250 Mail OK"
send "RCPT TO: <$to>\r"
expect "250 Mail OK"
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"
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章