Skip to content

Wrong line seperator in byte representation of messages #213

@moenoel

Description

@moenoel

The commit 0dba9d6 changed msg=msg.as_string() to msg=msg.as_bytes() when sending a message, but the as_bytes() override in utils.py defaults to \n as linesep and is called without arguments.

As smtplib converts single \n or \r to \r\n automatically with regular strings, but does not touch byte strings, this causes emails to be generated and sent with LF as the line seperator instead of the correct CRLF, which can cause a violation of RFC5321 section 4.5.3.1.6 with messages that become longer than 998 bytes.

msg.as_bytes() should be called with linesep='\r\n' to fix this.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions