ethereal-email

Create ethereal email addresses on the fly from your application.


License
EUPL-1.1
Install
npm install ethereal-email@1.0.0

Documentation

Ethereal Email

Create ethereal email addresses on the fly from your application.

EtherealEmail acquires a new email address from ethereal.email and starts listening for messages sent to this address.

This is useful for testing email applications where you want to use vanity addresses but also to be able to test how the final message looks like. There is an actual roundtrip over the internet so the message received by @ethereal.email addresses should look exactly like messages received by everybody else.

Usage

  1. Create a EtherealEmail object and setup mail handler using the connect() method
  2. Listen for the 'email' event to receive the newly generated temporary email address (looks like this: "19d2c455d3.e85056310a.7c47607b55@ethereal.email")
  3. Send mail to this email address however you like to, for example from your desktop Outlook, the generated email address is just as valid as any other address
  4. The email you sent is routed to the mail handler you set up with the EtherealEmail object

Retrieve parsed email

The mail object received is a simpleParser object documented in the MailParser docs.

'use strict';
const EtherealEmail = require('ethereal-email');

let inbox = new EtherealEmail();

inbox.on('email', email => {
    console.log('Listening for messages sent to <%s>', email);
});

inbox.connect(mail => {
    console.log('NEW MAIL!');
    console.log(mail);
});

Retrieve raw email stream

If you want to parse the incoming message yourself, then set raw to true

'use strict';
const EtherealEmail = require('ethereal-email');

let inbox = new EtherealEmail({
    raw: true
});

inbox.on('email', email => {
    console.log('Listening for messages sent to <%s>', email);
});

inbox.connect(mail => {
    console.log('NEW MAIL!');
    mail.pipe(process.stdout);
});

How does it work?

There is a MX server running on ethereal.email that proxies all messages to the connected clients, using randomly generated addresses. When your client connects to this server, then a random address is generated and all messages sent to this address are proxied to your client. If the connection between your client and the server breaks, then the address is lost forever.

License

EUPL-1.1