Skip to content

Instantly share code, notes, and snippets.

@comuttun
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save comuttun/4aa3c82a44f08c984e11 to your computer and use it in GitHub Desktop.

Select an option

Save comuttun/4aa3c82a44f08c984e11 to your computer and use it in GitHub Desktop.
#!/bin/bash
read_response() {
while read -u9 LINE; do
declare more_response=${LINE:3:1}
echo $LINE
[ "$more_response" != '-' ] && break
done
}
exec 9<>/dev/tcp/mx1.mail.yahoo.co.jp/25
read_response
echo -ne "EHLO localhost\r\n" >&9
read_response
echo -ne "MAIL FROM: <user@localhost>\r\n" >&9
read_response
echo -ne "RCPT TO: <someone@example.com>\r\n" >&9
read_response
# Result
#
# 220 mta508.mail.kks.yahoo.co.jp ESMTP YSmtp service ready
# 250-mta508.mail.kks.yahoo.co.jp
# 250-8BITMIME
# 250-SIZE 41943040
# 250 PIPELINING
# 250 sender <user@localhost> ok
# 550 relaying denied for <someone@example.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment