Skip to content

Commit

Permalink
v4.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Nov 10, 2017
1 parent f79ee37 commit 9cdb369
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# CHANGELOG

## 4.4.0 2017-11-10

- Changed default behavior for attachment option contentTransferEncoding. If it is unset then base64 encoding is used for the attachment. If it is set to false then previous default applies (base64 for most, 7bit for text)

## 4.3.1 2017-10-25

- Fixed a confict with Electron.js where timers do not have unref method
Expand Down
2 changes: 1 addition & 1 deletion lib/mail-composer/index.js
Expand Up @@ -94,7 +94,7 @@ class MailComposer {
data = {
contentType: attachment.contentType || mimeFuncs.detectMimeType(attachment.filename || attachment.path || attachment.href || 'bin'),
contentDisposition: attachment.contentDisposition || (isMessageNode ? 'inline' : 'attachment'),
contentTransferEncoding: attachment.contentTransferEncoding
contentTransferEncoding: 'contentTransferEncoding' in attachment ? attachment.contentTransferEncoding : 'base64'
};

if (attachment.filename) {
Expand Down
8 changes: 3 additions & 5 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "nodemailer",
"version": "4.3.1",
"version": "4.4.0",
"description": "Easy as cake e-mail sending from your Node.js applications",
"main": "lib/nodemailer.js",
"scripts": {
Expand All @@ -10,9 +10,7 @@
"type": "git",
"url": "https://github.com/nodemailer/nodemailer.git"
},
"keywords": [
"Nodemailer"
],
"keywords": ["Nodemailer"],
"author": "Andris Reinman",
"license": "MIT",
"bugs": {
Expand All @@ -33,7 +31,7 @@
"mocha": "^4.0.1",
"proxy": "^0.2.4",
"proxy-test-server": "^1.0.0",
"sinon": "^4.0.1",
"sinon": "^4.1.2",
"smtp-server": "^3.3.0"
},
"engines": {
Expand Down
58 changes: 55 additions & 3 deletions test/mail-composer/mail-composer-test.js
Expand Up @@ -553,6 +553,58 @@ describe('MailComposer unit tests', function() {
]
};

let expected =
'' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'Message-ID: <zzzzzz>\r\n' +
'Date: Sat, 21 Jun 2014 10:52:44 +0000\r\n' +
'MIME-Version: 1.0\r\n' +
'\r\n' +
'----_NmP-test-Part_1\r\n' +
'Content-Type: text/plain\r\n' +
'Content-Transfer-Encoding: 7bit\r\n' +
'\r\n' +
'abc\r\n-' +
'---_NmP-test-Part_1\r\n' +
'Content-Type: text/plain; name=test.txt\r\n' +
'X-Test-1: 12345\r\n' +
'X-Test-2: =?UTF-8?B?w5XDhMOWw5w=?=\r\n' +
'X-Test-3: foo\r\n' +
'X-Test-3: bar\r\n' +
'Content-Transfer-Encoding: base64\r\n' +
'Content-Disposition: attachment; filename=test.txt\r\n' +
'\r\n' +
'dGVzdA==\r\n' +
'----_NmP-test-Part_1--\r\n';

let mail = new MailComposer(data).compile();
mail.build(function(err, message) {
expect(err).to.not.exist;
expect(message.toString()).to.equal(expected);
done();
});
});

it('should keep plaintext for attachment', function(done) {
let data = {
text: 'abc',
baseBoundary: 'test',
messageId: 'zzzzzz',
date: 'Sat, 21 Jun 2014 10:52:44 +0000',
attachments: [
{
headers: {
'X-Test-1': 12345,
'X-Test-2': 'ÕÄÖÜ',
'X-Test-3': ['foo', 'bar']
},
content: 'test',
filename: 'test.txt',
contentTransferEncoding: false
}
]
};

let expected =
'' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
Expand Down Expand Up @@ -617,14 +669,14 @@ describe('MailComposer unit tests', function() {
'abc\r\n' +
'----_NmP-test-Part_1\r\n' +
'Content-Type: text/plain; name=test.txt\r\n' +
'Content-Transfer-Encoding: base64\r\n' +
'Content-Disposition: attachment; filename=test.txt\r\n' +
'Content-Transfer-Encoding: 7bit\r\n' +
'\r\n' +
'test\r\n' +
'dGVzdA==\r\n' +
'----_NmP-test-Part_1\r\n' +
'Content-Type: application/octet-stream\r\n' +
'Content-Disposition: attachment\r\n' +
'Content-Transfer-Encoding: base64\r\n' +
'Content-Disposition: attachment\r\n' +
'\r\n' +
'dGVzdDI=\r\n' +
'----_NmP-test-Part_1--\r\n';
Expand Down

0 comments on commit 9cdb369

Please sign in to comment.