17

I have found conflicting information about dot stuffing when transmitting an email.

  1. stuff a dot if the line contains a single dot (to avoid premature termination)
  2. stuff a dot to every line stat starts with a dot
  3. stuff a dot to (1) and to every line part of a quoted-printable message part only

Can anyone clarify?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
transilvlad
  • 13,974
  • 13
  • 45
  • 80

3 Answers3

31

According to the SMTP standard RFC 5321, section 4.5.2:

https://www.rfc-editor.org/rfc/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.

Community
  • 1
  • 1
chus
  • 1,577
  • 15
  • 25
  • If a server removes only one out of two dots on a line, it is doing exactly what the standard specifies. When the first character of a line of the original message is a period, the client adds another one before sending the message. Then, the server removes the added period. – chus Apr 20 '13 at 22:00
  • 1
    I meant it only removes one out of two IF THE WHOLE LINE CONTAINS ONLY TWO DOTS. Example: \r\n..\r\n But not for any other line. – transilvlad Apr 20 '13 at 22:53
  • I think now I can see the point. The solution depends on the agent your are implementing (MTA, MDA). May be you can identify the servers that are not RFC-compliant and process the message to preserve the original text. – chus Apr 20 '13 at 23:38
  • My problem is not the senders is the receivers. I am sending out DKIM signed emails that on some servers fail because of this. I spent months thinking it was my fault but eventually I managed to identify it was an issue on their side. Oddly enough they use various known agents but they must have done some modifications I guess. – transilvlad Apr 21 '13 at 00:53
6

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.

billm
  • 61
  • 1
  • 1
1

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.

transilvlad
  • 13,974
  • 13
  • 45
  • 80
Anshul
  • 1,416
  • 1
  • 16
  • 42