Skip to content

Commit

Permalink
Fix arithmetric#114 Sender email without name
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabrice Daugan committed Jan 16, 2020
1 parent d5cb050 commit 33f461e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,16 @@ exports.processMessage = function(data) {
fromText = 'From: ' + from.replace(/<(.*)>/, '').trim() +
' <' + data.config.fromEmail + '>';
} else {
// No name format
fromText = 'From: ' + from.replace('@', ' at ') +
// No display name format
fromText = 'From: ' + from.replace('@', ' at ').trim() +
' <' + data.config.fromEmail + '>';
}
} else if (from.indexOf('<') >= 0 && from.indexOf('>') >= 0) {
fromText = 'From: ' + from.replace('<', 'at ').replace('>', '') +
' <' + data.originalRecipient + '>';
} else {
// No name format
fromText = 'From: ' + from.replace('@', ' at ') +
// No display name format
fromText = 'From: ' + from.replace('@', ' at ').trim() +
' <' + data.originalRecipient + '>';
}
return fromText;
Expand Down
8 changes: 5 additions & 3 deletions test/processMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ describe('index.js', function() {
email: {
source: "[email protected]"
},
emailData: fs.readFileSync("test/assets/message.simplefrom.txt").toString(),
emailData:
fs.readFileSync("test/assets/message.simplefrom.txt").toString(),
log: console.log,
recipients: ["[email protected]"],
originalRecipient: "[email protected]"
Expand All @@ -52,15 +53,16 @@ describe('index.js', function() {
});
});

it('should process email data and handle the simple from format having a custom fromMail', function(done) {
it('should allow overriding the simple From header in emails', function(done) {
var data = {
config: {
fromEmail: "[email protected]"
},
email: {
source: "[email protected]"
},
emailData: fs.readFileSync("test/assets/message.simplefrom.txt").toString(),
emailData:
fs.readFileSync("test/assets/message.simplefrom.txt").toString(),
log: console.log,
recipients: ["[email protected]"],
originalRecipient: "[email protected]"
Expand Down

0 comments on commit 33f461e

Please sign in to comment.