Ticket #5232: telnet-an-email

File telnet-an-email, 2.5 KB (added by isis, 7 years ago)

Adding my embarrassing pexpect + raw SMTP/telnet script that I use for testing the email server. (I didn't want to commit it to the repo.) To use it, do: ./telnet-an-email $USER

Line 
1#!/usr/bin/env expect
2#
3# -*- coding: utf-8 -*-
4#
5# telnet-an-email
6# ---------------
7# Telnet to a local running test instance of BridgeDB's email distributor, and
8# speak raw SMTP to it to send an email with the line "get bridges". Useful
9# for testing BridgeDB's email responder without involving potential bugs in
10# Python, Twisted, or a full SMTP server.
11#_____________________________________________________________________________
12#
13# This file is part of BridgeDB, a Tor bridge distribution system.
14#
15# :authors: Isis Lovecruft 0xA3ADB67A2CDB8B35 <isis@torproject.org>
16#           please also see AUTHORS file
17# :copyright: (c) 2007-2013, The Tor Project, Inc.
18#             (c) 2007-2013, all entities within the AUTHORS file
19# :license: 3-clause BSD, see included LICENSE for information
20#_____________________________________________________________________________
21
22set timeout 20
23set host 127.0.0.1
24set port 6725
25set mailfrom [lindex $argv 0]
26
27spawn telnet $host $port
28
29expect {
30       "Connected to"                   {send "HELO localhost\r"; exp_continue}
31       "Hello $host, nice to meet you"  {send "MAIL FROM: $mailfrom@$host\r"; exp_continue}
32       "250 Sender address accepted"    {send "RCPT TO: bridges@$host\r"; exp_continue}
33       "250 Recipient address accepted" {send "DATA\r"; exp_continue}
34       "354 Continue"                   {send "From: $mailfrom@$host
35To: bridges@$host
36Subject: testing
37
38get bridges
39.\r"; exp_continue}
40        "250 Delivery in progress"      {send "QUIT\r"; exp_continue}
41        "221 See you later"             exit
42}
43
44
45# expect "Connected to"
46# send "HELO localhost
47# "
48# expect "Hello 127.0.0.1, nice to meet you"
49# send "MAIL FROM: $mailfrom@patternsinthevoid.net\r"
50# expect "250 Sender address accepted"
51# send "RCPT TO: bridges@$host\r"
52# expect "250 Recipient address accepted"
53# send "DATA\r"
54# expect "354 Continue"
55# send "From: $mailfrom@patternsinthevoid.net\r
56# Subject: testing\r
57# \r
58# get bridges\r
59# .\r"
60# expect "250 Delivery in progress"
61# send "QUIT\r"
62# expect "221 See you later"
63
64
65#interact
66
67# function usage () {
68#     printf "Usage: %s\n\n" $NAME
69#     printf "This script will use telnet to interactively speak SMTP to to a test instance\n"
70#     printf "(at bridges@127.0.0.1) of BridgeDB's email responder. Useful for testing\n"
71#     printf "BridgeDB's email server without involving potential bugs in Twisted, Python, or\n"
72#     printf "a full SMTP server.\n"
73#     printf "\n"
74# }
75# if test "$#" -gt "1" ; then usage ; fi