Skip to content

Period at the beginning of line of encoded content #67

@level-xx

Description

@level-xx

First of all: Many thanks for this great work, it helped me a lot!

Describe the bug

After encoding and line breaking it may occur that a line starts with a period. This may lead to problems with the SMTP server which may take the period as the »end of message« and treat the rest of the message as commands, resulting in a mess, of course :)

Content lines starting with a period are non-compliant with RFC5321 which says in section 4.5.2 that if the first character of the line is a period, one additional period has to be inserted at the beginning of the line.

To Reproduce

A message with a line consisting of 75 dots at the beginning will do the trick -- at least on my SMTP server.

Logs

Deno will yield a bad resource error when the SMTP server closes the connection.

error: Uncaught BadResource: Bad resource ID
    at async Object.write (internal:ext/web/06_streams.js:902:11)

Proposed solution

Check for lines starting with a period in denomailer/config/mail/encoding.ts and prepend a period if necessary. At line 46 add something like

    if (old.startsWith('.')) {
      old = "." + old;
    }

This is how I fixed it, although I am not sure if this breaks something else.

I can provide a PR if so desired.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions