When using telnet or netcat to test an outgoing SMTP email I cannot end message 'with “.” on a line by itself'

匿名 (未验证) 提交于 2019-12-03 01:00:01

问题:

When sending a simple email via telnet or netcat to my ISP's SMTP server I cannot terminate the message with a period. Eventually the connection times out but the message is not delivered.

root@zeus:/tmp# telnet mail.charter.net 25 220 imp09 smtp.charter.net ESMTP server ready 20110115 000442 HELO charter.net 250 imp09 hello [97.94.115.109], pleased to meet you MAIL FROM: test@gmail.com 250 2.1.0 <test@gmail.com> sender ok RCPT TO: test@gmail.com 250 2.1.5 <test@gmail.com> recipient ok DATA 354 enter mail, end with "." on a line by itself test body  .  .  /n. /n .  \n .  QUIT 

This works fine on another computer on the same network and ISP with a different version of telnet.

netcat hangs the same way on both computers.

I was thinking this may have something to do with LINEMODE, as the telnet session that cannot send the email is in LINEMODE and cannot switch to CHARMODE. Are there any work arounds?

回答1:

The newlines you are sending are probably just a carriage return or just a linefeed character. SMTP requires a carriage return followed by a line feed to end a line.

http://tools.ietf.org/html/rfc5321#section-2.3.8

http://tools.ietf.org/html/rfc5321#section-4.1.1.4

Try ending each line with Control-M Control-J, using a different terminal program, and/or using something other than telnet.



回答2:

A shot in the dark, but maybe try pressing CTRL-J instead of Enter after typing the ..



回答3:

To see what's really going on you can use one of these tools:

  • strace records all system calls, including everything you write or read to files or the network. You can examine the output of that program to see if the lines are properly terminated by \r\n.
  • wireshark records and displays network traffic. Use it to record the traffic, filter on tcp.port==25 and then Follow TCP stream to see which bytes have really been sent over the wire.


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!