Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zone-mta

Package Overview
Dependencies
Maintainers
1
Versions
334
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zone-mta - npm Package Compare versions

Comparing version 0.1.0-alpha.11 to 0.1.0-alpha.12

3

config/default.js

@@ -31,2 +31,4 @@ 'use strict';

enabled: ['main', 'sender'],
// Add missing headers (Message-ID, Date, etc.)
addMissing: true,
// If true then delay messages according to the Date header. Messages can be deferred up to 1 year.

@@ -68,2 +70,3 @@ // This only works if the Date header is higher than 5 minutes from now because of possible clock skew

url: 'http://localhost:11333/check',
interfaces: ['feeder'],
rejectSpam: true // if false, then the message is passed on with a spam header, otherwise message is rejected

@@ -70,0 +73,0 @@ },

2

package.json
{
"name": "zone-mta",
"private": false,
"version": "0.1.0-alpha.11",
"version": "0.1.0-alpha.12",
"description": "Tiny outbound MTA",

@@ -6,0 +6,0 @@ "main": "app.js",

@@ -19,5 +19,7 @@ 'use strict';

if (!mId) {
envelope.headers.remove('message-id'); // in case there's an empty value
mId = '<' + uuid.v4() + '@' + (envelope.from.substr(envelope.from.lastIndexOf('@') + 1) || hostname) + '>';
envelope.headers.add('Message-ID', mId);
if (app.config.addMissing) {
envelope.headers.remove('message-id'); // in case there's an empty value
envelope.headers.add('Message-ID', mId);
}
}

@@ -64,3 +66,5 @@ envelope.messageId = mId;

from.address = rewriteFrom.address || from.address || envelope.from || ('auto-generated@' + hostname);
envelope.headers.update('From', from.name ? from.name + ' <' + from.address + '>' : from.address);
if (app.config.addMissing || envelope.rewriteFrom) {
envelope.headers.update('From', from.name ? from.name + ' <' + from.address + '>' : from.address);
}

@@ -76,5 +80,7 @@ if (rewriteFrom.address) {

if (!date || dateVal.toString() === 'Invalid Date' || dateVal < new Date(1000)) {
envelope.headers.remove('date'); // remove old empty or invalid values
date = new Date().toUTCString().replace(/GMT/, '+0000');
envelope.headers.add('Date', date);
if (app.config.addMissing) {
envelope.headers.remove('date'); // remove old empty or invalid values
envelope.headers.add('Date', date);
}
}

@@ -127,37 +133,39 @@

app.addHook('sender:headers', (delivery, next) => {
// Ensure that there is at least one recipient header
if (app.config.addMissing) {
app.addHook('sender:headers', (delivery, next) => {
// Ensure that there is at least one recipient header
let hasRecipient = false;
let hasContent = false;
let hasMime = false;
let hasRecipient = false;
let hasContent = false;
let hasMime = false;
let keys = delivery.headers.getList().map(line => line.key);
for (let i = 0, len = keys.length; i < len; i++) {
if (!hasRecipient && ['to', 'cc', 'bcc'].includes(keys[i])) {
hasRecipient = true;
let keys = delivery.headers.getList().map(line => line.key);
for (let i = 0, len = keys.length; i < len; i++) {
if (!hasRecipient && ['to', 'cc', 'bcc'].includes(keys[i])) {
hasRecipient = true;
}
if (!hasMime && keys[i] === 'mime-version') {
hasMime = true;
}
if (!hasContent && ['content-transfer-encoding', 'content-type', 'content-disposition'].includes(keys[i])) {
hasContent = true;
}
}
if (!hasMime && keys[i] === 'mime-version') {
hasMime = true;
if (!hasRecipient) {
// No recipient addresses found, add a To:
// This should not conflict DKIM signature
delivery.headers.add('To', delivery.envelope.to);
}
if (!hasContent && ['content-transfer-encoding', 'content-type', 'content-disposition'].includes(keys[i])) {
hasContent = true;
if (hasContent && !hasMime) {
// Add MIME-Version to bottom
delivery.headers.add('MIME-Version', '1.0', Infinity);
}
}
if (!hasRecipient) {
// No recipient addresses found, add a To:
// This should not conflict DKIM signature
delivery.headers.add('To', delivery.envelope.to);
}
next();
});
}
if (hasContent && !hasMime) {
// Add MIME-Version to bottom
delivery.headers.add('MIME-Version', '1.0', Infinity);
}
next();
});
done();
};

@@ -41,4 +41,4 @@ 'use strict';

subject: 'Delivery Status Notification (Failure)',
text: 'Delivery to the following recipient failed permanently:\n ' + bounce.to + '\n' +
'Technical details of permanent failure:\n' + bounce.response + '\n\n\n----- Original message -----\n' +
text: 'Delivery to the following recipient failed permanently:\n ' + bounce.to + '\n\n' +
'Technical details of permanent failure:\n\n' + bounce.response + '\n\n\n----- Original message -----\n' +
headers.build().toString().trim() + '\n\n----- Message truncated -----'

@@ -45,0 +45,0 @@ });

@@ -9,2 +9,6 @@ 'use strict';

app.addAnalyzerHook((envelope, source, destination) => {
if (!app.config.interfaces.includes(envelope.interface)) {
return source.pipe(destination);
}
let rspamdStream = new RspamdClient({

@@ -28,3 +32,3 @@ url: app.config.url,

rspamdStream.once('error', err => {
destination.emit('error', err);
source.emit('error', err);
});

@@ -36,2 +40,6 @@

app.addHook('message:queue', (envelope, next) => {
if (!app.config.interfaces.includes(envelope.interface)) {
return next();
}
if (app.config.rejectSpam && envelope.spam && envelope.spam.default && envelope.spam.default.is_spam) {

@@ -38,0 +46,0 @@ let err = new Error('This message was classified as SPAM and may not be delivered');

@@ -7,3 +7,3 @@ 'use strict';

const dbfolder = path.join(__dirname, 'queuetest');
const createQueue = require('../lib/mail-queue');
const MailQueue = require('../lib/mail-queue');
const PassThrough = require('stream').PassThrough;

@@ -19,3 +19,3 @@

db.on('ready', () => {
queue = createQueue({
queue = new MailQueue({
db

@@ -22,0 +22,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc