Created
July 29, 2009 00:19
-
-
Save geoffgarside/157771 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usage: $0 hostname email_addr | |
# | |
# Performs a basic SMTP delivery check, it connects to the target SMTP server, sends | |
# a HELO command, then a MAIL FROM followed by a RCPT TO. This should verify that | |
# the server is a) contactable b) permits the sender and c) accepts the recipient. | |
require 'socket' | |
require 'net/telnet' | |
me = Socket.gethostname | |
tn = Net::Telnet.new('Host' => ARGV[0], 'Port' => 25, 'Prompt' => /^[0-9]{3}\s.*$/) | |
puts "Connection established..." | |
tn.waitfor(/220\s.*$/) | |
tn.cmd("HELO #{me}") | |
puts "HELO sent..." | |
puts "Sending mail from test@#{me} -> #{ARGV[1]}..." | |
tn.cmd("MAIL FROM: test@#{me}") | |
puts "SMTP Server Response to RCPT TO..." | |
puts tn.cmd("RCPT TO: #{ARGV[1]}") | |
tn.cmd("QUIT") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment