You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When setting the newline option to 'unix' in StreamTransport, the returned newlines are still CRLF (Windows-style) instead of the expected LF (Unix-style).
Additionally, you can define which kind of newlines to use, either the 'windows' style (<CR><LF>) or the 'unix' style (<LF>)
However, when running the following test code based on the sample code provided in the documentation, the returned newline characters are still \r\n, failing the test.
Test Code:
'use strict';const{ describe, it }=require('node:test');constassert=require('node:assert/strict');const{createTransport}=require('../lib/nodemailer');describe('Stream Transport Tests',{timeout: 10000},()=>{it('Should send mail using unix newlines',(t,done)=>{lettransporter=createTransport({streamTransport: true,newline: 'unix',buffer: true});transporter.sendMail({from: 'sender@example.com',to: 'recipient@example.com',subject: 'Message',text: 'I hope this message gets buffered!',},(err,info)=>{console.log(`info message: \n${JSON.stringify(info.message.toString())}`);assert.ok(!err);assert.strictEqual(info.message.toString().includes('\r\n'),false);done();})});});
The root cause seems to be that the newline: 'unix' option set in options is not being passed to the MailComposer at Mail#sendMail L182.
Possible Solution:
The easiest workaround would be to set newline: 'unix' in the first argument of sendMail. However, this approach may not be appropriate since newline is not a property of email data. (Additionally, while Nodemailer itself does not have an issue, the newline option is not defined in the Mail.Options type definition for Nodemailer. see: https://github.com/DefinitelyTyped/DefinitelyTyped)
If this solution is not viable, unfortunately, I cannot suggest an optimal solution.
I understand that you are incredibly busy, I would appreciate your confirmation and feedback.
Environment:
node: v20.12.0
npm: v10.5.0
nodemailer: v6.9.13
The text was updated successfully, but these errors were encountered:
I checked, and you are right. However, at this point, as this feature is so old and no one has ever complained about it, the correct way would probably be to completely remove this feature instead of fixing it. Is there are reason why you need the eml to be using unix newlines?
If there are currently few cases where this feature is being used, and the cost of fixing it is substantial, then I would agree with removing this feature in the future.
Or, if no defects occur in functions otherthan newline, how about considering abolishing only the 'newline' property?
Issue Description:
When setting the newline option to 'unix' in StreamTransport, the returned newlines are still CRLF (Windows-style) instead of the expected LF (Unix-style).
The official documentation states:
However, when running the following test code based on the sample code provided in the documentation, the returned newline characters are still
\r\n
, failing the test.Test Code:
Possible Root Cause:
The root cause seems to be that the
newline: 'unix'
option set inoptions
is not being passed to theMailComposer
at Mail#sendMail L182.Possible Solution:
The easiest workaround would be to set
newline: 'unix'
in the first argument ofsendMail
. However, this approach may not be appropriate sincenewline
is not a property of email data. (Additionally, while Nodemailer itself does not have an issue, thenewline
option is not defined in theMail.Options
type definition for Nodemailer. see: https://github.com/DefinitelyTyped/DefinitelyTyped)If this solution is not viable, unfortunately, I cannot suggest an optimal solution.
I understand that you are incredibly busy, I would appreciate your confirmation and feedback.
Environment:
The text was updated successfully, but these errors were encountered: