mailhog / smtp

MailHog SMTP Protocol
MIT License
74 stars 31 forks source link

scripted telnet doesn't work #1

Closed dknecht closed 9 years ago

dknecht commented 9 years ago
telnet 127.0.0.1 25 << EOF
HELO cloudflare.com
MAIL FROM:<test@test.com>
RCPT TO:<test2@test.com>
DATA
Body of email.
.
QUIT
EOF

I tested this with postfix and other mtas with no issues.

ian-kent commented 9 years ago

I've tried to validate it using gmail and my own postfix installation, and can't get that to work at all - they both behave in the same was as MailHog.

telnet doesn't give any useful output, but the postfix log output shows this:

Feb 25 20:29:46 ubuntu postfix/smtpd[7435]: connect from hostnnn-nnn-nnn-nnn.nnnnn-nnn.somehost.com[nnn.nnn.nnn.nnn]
Feb 25 20:29:46 ubuntu postfix/smtpd[7435]: lost connection after CONNECT from hostnnn-nnn-nnn-nnn.nnnnn-nnn.somehost.com[nnn.nnn.nnn.nnn]
Feb 25 20:29:46 ubuntu postfix/smtpd[7435]: disconnect from hostnnn-nnn-nnn-nnn.nnnnn-nnn.somehost.com[nnn.nnn.nnn.nnn]

aside from that, this is invalid use of SMTP protocol - SMTP is conversational, and passing data to telnet (or netcat) via STDIN isn't. even with SMTP pipelining the client is required to wait until the server has confirmed pipelining support after a successful EHLO before it sends multiple commands.

to script an SMTP conversation you could use something like expect - there's an example at the bottom of this page