Skip to content

Commit 33f461e

Browse files
author
Fabrice Daugan
committed
Fix arithmetric#114 Sender email without name
1 parent d5cb050 commit 33f461e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,16 @@ exports.processMessage = function(data) {
210210
fromText = 'From: ' + from.replace(/<(.*)>/, '').trim() +
211211
' <' + data.config.fromEmail + '>';
212212
} else {
213-
// No name format
214-
fromText = 'From: ' + from.replace('@', ' at ') +
213+
// No display name format
214+
fromText = 'From: ' + from.replace('@', ' at ').trim() +
215215
' <' + data.config.fromEmail + '>';
216216
}
217217
} else if (from.indexOf('<') >= 0 && from.indexOf('>') >= 0) {
218218
fromText = 'From: ' + from.replace('<', 'at ').replace('>', '') +
219219
' <' + data.originalRecipient + '>';
220220
} else {
221-
// No name format
222-
fromText = 'From: ' + from.replace('@', ' at ') +
221+
// No display name format
222+
fromText = 'From: ' + from.replace('@', ' at ').trim() +
223223
' <' + data.originalRecipient + '>';
224224
}
225225
return fromText;

test/processMessage.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ describe('index.js', function() {
3636
email: {
3737
source: "betsy@example.com"
3838
},
39-
emailData: fs.readFileSync("test/assets/message.simplefrom.txt").toString(),
39+
emailData:
40+
fs.readFileSync("test/assets/message.simplefrom.txt").toString(),
4041
log: console.log,
4142
recipients: ["jim@example.com"],
4243
originalRecipient: "info@example.com"
@@ -52,15 +53,16 @@ describe('index.js', function() {
5253
});
5354
});
5455

55-
it('should process email data and handle the simple from format having a custom fromMail', function(done) {
56+
it('should allow overriding the simple From header in emails', function(done) {
5657
var data = {
5758
config: {
5859
fromEmail: "noreply@example.com"
5960
},
6061
email: {
6162
source: "betsy@example.com"
6263
},
63-
emailData: fs.readFileSync("test/assets/message.simplefrom.txt").toString(),
64+
emailData:
65+
fs.readFileSync("test/assets/message.simplefrom.txt").toString(),
6466
log: console.log,
6567
recipients: ["jim@example.com"],
6668
originalRecipient: "info@example.com"

0 commit comments

Comments
 (0)