SMTP dot stuffing.. when and where to do it?

六眼飞鱼酱① 提交于 2019-12-04 03:19:12

According to the SMTP standard RFC 5321, section 4.5.2:

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

To allow all user composed text to be transmitted transparently, the following procedures are used:

  • Before sending a line of mail text, the SMTP client checks the first character of the line. If it is a period, one additional period is inserted at the beginning of the line.
  • When a line of mail text is received by the SMTP server, it checks the line. If the line is composed of a single period, it is treated as the end of mail indicator. If the first character is a period and there are other characters on the line, the first character is deleted.

So, from the three points of your question, the second one is right.

The practical answer: If you're using quoted printable format then always translate a dot to =2E. You can't rely on all smtp servers doing the dot removal correctly.

If you want to assume the whole world is standards compliant then go with answer 2 above.

Anshul

In SMTP protocol the mail is terminated by a single dot and a newline character(s)

In simple terms something like:

\r\n.\r\n

The characters:

CR LF DOT CR LF

Which corresponds to a single dot at the beginning of a line.

In case the mail data contains a single . At the beginning of line and is followed by a new line character then the SMTP protocol will consider it as mail termination and hence only a part of mail would be delivered.

So the whole idea is to avoid these type of situation by padding an extra dot.

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