mhale / smtpd

An SMTP server package written in Go, in the style of the built-in HTTP server.
The Unlicense
397 stars 92 forks source link

Parse DATA error? #2

Closed DeadNumbers closed 8 years ago

DeadNumbers commented 8 years ago

How to send DATA end? https://github.com/mhale/smtpd/blob/master/smtpd.go#L252

$ nc localhost 2525
220 localhost MyServerApp SMTP Service ready
EHLO hello server
250 localhost greets hello server
MAIL FROM:<admin@google.com>
250 Ok
RCPT TO:<admin@nasa.gov>
250 Ok
DATA
354 Start mail input; end with <CR><LF>.<CR><LF>
From:admin@google.com
To:admin@nasa.gov
Subject:Test

<h1>Test</h1>

\r\n.\r\n

.\r\n

but nothing.

My locale

LANG=ru_RU.UTF-8
LC_CTYPE=ru_RU.UTF-8
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=
mhale commented 8 years ago

It seems like you're typing or pasting the \r and \n directly into your terminal, which means they are being interpreted literally instead of being interpreted as control characters. If you want to use Netcat, try putting the entire exchange in quotes on a single line, then pipe it to nc like this:

$ msg="EHLO hello server\nMAIL FROM:<admin@google.com>\nRCPT TO:<admin@nasa.gov>\nDATA\nFrom:admin@google.com\r\nTo:admin@nasa.gov\r\nSubject:Test\r\n\r\n<h1>Test</h1>\r\n.\r\n";
$ echo -ne $msg | nc localhost 2525
DeadNumbers commented 8 years ago

@mhale thanks.