使用expect自动发送邮件的脚本
#!/usr//bin/expect
spawn telnet mail.domain.com 25
expect "220"
send "ehlo mail.domain.com "
spawn telnet mail.domain.com 25
expect "220"
send "ehlo mail.domain.com "
expect "HELP"
send "auth login "
send "auth login "
expect "334"
send "邮件用户名(base64编码) "
send "邮件用户名(base64编码) "
expect "334"
send "密码(base64编码) "
send "密码(base64编码) "
expect "235"
send "mail from:dominic.zhang@domain.com "
send "mail from:dominic.zhang@domain.com "
expect "250"
send "rcpt to:jack@domain.com "
send "rcpt to:jack@domain.com "
expect "250"
send "data From: dominic.zhang@domain.com To: jack@domain.com Date: Subject: test mail HI,test dominic's test . "
send "data From: dominic.zhang@domain.com To: jack@domain.com Date: Subject: test mail HI,test dominic's test . "
expect "250"
send "quit "
send "quit "
转载于:https://blog.51cto.com/liweizhong/597547