smtp-forward
v0.1.2
Published
Receive and forward emails to web service
Downloads
3
Readme
SMTP Forward
Receive and forward emails to web service.
Install
npm i smtp-forward
Usage
const forward = require('smtp-forward')
forward({ port: 2525, onMail: async function(mail) {
// Forward to web service or something else
console.log(mail)
}})
// With automatic upload to S3
const upload = {
key: AMAZON_KEY,
secret: AMAZON_SECRET,
bucket: AMAZON_BUCKET
}
forward({ port: 2525, upload, onMail: async function(mail) {
console.log(mail)
}})
Schema
The mail object looks like this:
{
messageId: '<[email protected]>',
to: '[email protected]',
from: 'Fred Foo 👻 <[email protected]>',
subject: 'Hello ✔',
text: 'Are you ready?',
html: '<b>Are you ready?</b>',
headers: {
'content-type': 'Content-Type: multipart/alternative;\r\n' +
' boundary="--_NmP-1d24f3de9d13035d-Part_1"',
from: 'From: =?UTF-8?Q?Fred_Foo_=F0=9F=91=BB?= <[email protected]>',
to: 'To: [email protected]',
subject: 'Subject: =?UTF-8?Q?Hello_=E2=9C=94?=',
'message-id': 'Message-ID: <[email protected]>',
date: 'Date: Sun, 12 Jun 2022 13:46:16 +0000',
'mime-version': 'MIME-Version: 1.0'
},
// undefined or string of space separated messageIds
references: undefined,
// undefined or string as messageId
inReplyTo: undefined,
// Array of attachments, see below for spec
attachments: []
}
The attachment object looks like this:
{
name: 'url-to-file.jpg',
// If you use uploads
url: 'https://example.com/url-to-file.jpg',
// Path on your computer
path: '/tmp/url-to-file.jpg',
type: 'image/jpg',
size: 12345
}
MIT Licensed. Enjoy!