diff --git a/index.js b/index.js index 27510a3..90d37e4 100644 --- a/index.js +++ b/index.js @@ -203,7 +203,7 @@ exports.increment_forward_counters = async function (connection) { const ttlres = await plugin.ttlcounterAsync('wdf:' + key, increment, limit, false); connection.loginfo(plugin, `Forward counter updated for ${key} (${increment}/${limit}): ${JSON.stringify(ttlres)}`); } catch (err) { - connection.logerror(plugin, err); + connection.logerror(plugin, err.message); } } }; @@ -543,7 +543,7 @@ exports.hook_rcpt = function (next, connection, params) { returned = true; const err = args && args[0]; if (err && /Error$/.test(err.name)) { - connection.logerror(plugin, err); + connection.logerror(plugin, err.message); txn.notes.rejectCode = 'ERRC01'; return next(DENYSOFT, 'Failed to process recipient, try again [ERRC01]'); } @@ -1193,7 +1193,7 @@ exports.hook_queue = function (next, connection) { .increment_forward_counters(connection) .then(next) .catch(err => { - connection.logerror(plugin, err); + connection.logerror(plugin, err.message); next(); }); } diff --git a/lib/auth.js b/lib/auth.js index 3a3bf18..25599ad 100644 --- a/lib/auth.js +++ b/lib/auth.js @@ -10,6 +10,7 @@ const { parseReceived } = require('mailauth/lib/parse-received'); async function hookMail(plugin, connection, params) { const txn = connection?.transaction; + if (!txn) { return; } @@ -33,7 +34,7 @@ async function hookMail(plugin, connection, params) { txn.notes.spfResult = spfResult; } catch (err) { txn.notes.spfResult = { error: err }; - plugin.logerror(err, plugin, connection); + connection.logerror(plugin, err.message); return; } @@ -71,7 +72,7 @@ async function hookDataPost(stream, plugin, connection) { } } catch (err) { txn.notes.dkimResult = { error: err }; - plugin.logerror(err, plugin, connection); + connection.logerror(plugin, err.message); } // Step 3. ARC @@ -89,7 +90,7 @@ async function hookDataPost(stream, plugin, connection) { } } catch (err) { txn.notes.arcResult = { error: err }; - plugin.logerror(err, plugin, connection); + connection.logerror(plugin, err.message); } } @@ -121,7 +122,7 @@ async function hookDataPost(stream, plugin, connection) { } } catch (err) { txn.notes.dmarcResult = { error: err }; - plugin.logerror(err, plugin, connection); + connection.logerror(plugin, err.message); } } @@ -147,7 +148,7 @@ async function hookDataPost(stream, plugin, connection) { txn.remove_header('bimi-indicator'); } catch (err) { txn.notes.bimiResult = { error: err }; - plugin.logerror(err, plugin, connection); + connection.logerror(plugin, err.message); } } @@ -186,8 +187,8 @@ async function hookDataPost(stream, plugin, connection) { _dkim_selector: result.selector, _dkim_algo: result.algo, _dkim_mod_len: result.modulusLength, - _dkim_canon_header: result.format.split('/').shift(), - _dkim_canon_body: result.format.split('/').pop(), + _dkim_canon_header: result.format?.split('/').shift(), + _dkim_canon_body: result.format?.split('/').pop(), _dkim_body_size_source: result.sourceBodyLength, _dkim_body_size_canon: result.canonBodyLengthTotal, _dkim_body_size_limit: result.canonBodyLengthLimited && result.canonBodyLengthLimit, diff --git a/lib/hooks.js b/lib/hooks.js index dcd724f..f640cef 100644 --- a/lib/hooks.js +++ b/lib/hooks.js @@ -39,7 +39,7 @@ function dataPost(next, plugin, connection) { next(); }) .catch(err => { - plugin.logerror(err, plugin, connection); + connection.logerror(plugin, err.message); next(); });