Skip to content

Instantly share code, notes, and snippets.

@yaasita
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaasita/9380519 to your computer and use it in GitHub Desktop.
Save yaasita/9380519 to your computer and use it in GitHub Desktop.
#!/usr/bin/expect
set timeout 10
spawn telnet mail.example.com 25
expect {
default {exit 2}
"ESMTP Postfix"
}
# helo
send "HELO sender.example.com\n"
expect {
default {exit 2}
"postfix.example.com"
}
# envelope-from
send "MAIL FROM: <my@sender.example.com>\n"
expect {
default {exit 2}
"250"
}
# not exists
send "RCPT TO: <not_found@example.com>\n"
expect {
default {exit 2}
"rejected"
}
# Third-Party Mail Relay
send "RCPT TO: <other_domain@other.example.com>\n"
expect {
default {exit 2}
"denied"
}
# ok
send "RCPT TO: <yamasita@example.com>\n"
expect {
default {exit 2}
"Ok"
}
send "QUIT\n"
interact
puts [exec echo Finished]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment