diff --git a/lib/appenders/smtp.js b/lib/appenders/smtp.js index 2023604..85accee 100644 --- a/lib/appenders/smtp.js +++ b/lib/appenders/smtp.js @@ -26,26 +26,26 @@ function smtpAppender(config, layout) { var transport = mailer.createTransport(config.transport, config[config.transport]); var firstEvent = logEventBuffer[0]; - var body = logEventBuffer.map(layout).join('\n'); + var body = ""; + while (logEventBuffer.length > 0) { + body += layout(logEventBuffer.shift()) + "\n"; + } + var msg = { to: config.recipients, subject: config.subject || subjectLayout(firstEvent), text: body, headers: { "Hostname": os.hostname() } }; - if (config.sender) { msg.from = config.sender; } - transport.sendMail(msg, function(error, success) { if (error) { console.error("log4js.smtpAppender - Error happened", error); } transport.close(); }); - - logEventBuffer = []; } }