expect 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"

本文来自CSDN博客,转载请标明出处: http://blog.csdn.net/smallfish_xy/archive/2009/09/08/4530876.aspx

你可能感兴趣的:(职场,telnet,expect,发送邮件,休闲)