An EML module for Node.
const _ = eml(
recipient('Tomas Hubelbauer', '[email protected]'),
name('Tomas Hubelbauer', '[email protected]'),
subject('Test Email'),
'Hi there!',
'<p>Check out this picture:</p>',
`<img src="${inline('hi.png', await fs.readFile('hi.png'))}" />`,
`<p>It's CID is ${inline('hi.png')}.</p>`,
`<p>Check it out again: <img src="${inline('hi.png')}" />.</p>`,
'<p>See your crap attached.</p>',
attachment('crap.csv', await fs.readFile('crap.csv')),
'Thanks!'
);
- Has helpers for various common headers
- Generates plain text version from an HTML email
- Has helpers for inline and attached files
- Slices related contents representation to 76 MIME characters automatically
- Slices long HTML lines to 76 MIME characters automatically and correctly
npm install https://github.com/TomasHubelbauer/eml
eml(
'string',
7, // number
helper(),
…
)
subject('subject')
sender('name', 'email')
or sender('email')
recipient('name', 'email')
or recipient('email')
inline('name', 'type', buffer)
Use in HTML through <img src="cid:name@" />
.
The stuff documented in this readme is working and there are some tests, too.
Initial release with the subject
, sender
, recipient
and inline
helpers.
node test
(with or without extension) npx nodemon test.js
(with extension)
to run the tests on each change.
Do not split tag name, attribute names and attributes values. Do not split words.
Subject, sender(s), recipient(s) etc.
Probably by concatenating multiple instances of the helper.