elixir-mail icon indicating copy to clipboard operation
elixir-mail copied to clipboard

7bit encoded email with line break

Open 03xb7 opened this issue 4 years ago • 4 comments

Hello. Maybe a dumb question but I can't see how the lib can successfully parse a 7bit encoded email that contain line breaks. By successfully I mean without losing line breaks.

Version

mail 0.2.3 Erlang/OTP 24 [erts-12.3.2.6] [source] [64-bit] [smp:5:5] [ds:5:5:10] [async-threads:1] Elixir 1.14.0 (compiled with Erlang/OTP 24)

Test Case

Using the parse_email function defined in parser test:

parse_email("""
    To: [email protected]
    From: [email protected]
    Subject: Test Email
    Content-Transfer-Encoding: 7bit

    This is the body!
    It has more than one line
    """)

Steps to reproduce

Run the above code

Expected Behavior

The returned body should have some sort of line breaks: This is the body!\nIt has more than one line

Actual Behavior

The returned body no longer have line breaks: This is the body!It has more than one line

Reading at the code, I see that the lib joins the body lines using \r\n but the SevenBit parser called just after drops them. Am I missing something ?

Joining the body lines with \n instead of \r\n seems to fix the issue.

Thanks in advance

PS: I saw the previous issue on the matter but could not find an answer there so I allowed myself to repost a new issue.

03xb7 avatar Nov 22 '22 09:11 03xb7

Is @andrewtimberlake 's answer in #138 not sufficient?

bcardarella avatar Nov 22 '22 13:11 bcardarella

I agree with Andrew's RFC understanding but the direct conclusion is that we can't send multi-line emails with this encoding. That can't be possible, I must be missing something.

May I add that python email module parses the same email without loosing line breaks.

03xb7 avatar Nov 22 '22 16:11 03xb7

@htulipe so your issue is not with the parsing but the compilation from the data structure into an email?

bcardarella avatar Nov 22 '22 18:11 bcardarella

My goal is to read an EML file and transform it in some data structure that my frontend end can then display.

03xb7 avatar Nov 23 '22 08:11 03xb7