This package has been deprecated

Author message:

This package is now maintained as fluid-mail-test.


1.0.6 • Public • Published


This package provides a test mail server based on simplesmtp, and a mail client based on nodemailer-smtp-transport.

Global Functions


  • Returns: Nothing.

Require the files that define our case holder and environment (see below). Allows third-parties to more easily reuse our test fixtures.



A test mail server that allows you to examine the contents of outgoing mail messages from within Fluid IoC tests. This allows you to do things like:

  1. Confirm that a link send to a user via email is actually usable.
  2. Confirm that mail message content is rendered correctly.

When a message is received, it is saved to the cache file, and then an onMessageReceived event is fired. In your tests you will typically:

  1. Send mail.
  2. Listen for the onMessageReceived event.
  3. Examine the contents of {gpii.test.mail.smtp}.currentMessageFile.

Note that the filename for the cache file is generated using a timestamp, and is located in os.tmpdir() by default.

Component Options

Option Type Description
port {Number} The port number to listen on. Defaults to 4025.
simpleSmtp {Object} The configuration options to pass on to simplesmtp.createServer. See the simplesmtp documentation for details.


A wrapper around nodemailer-smtp-transport that can be used to send test messages to an arbitrary SMTP server.

Component Options

Option Type Description
transportOptions {Object} Configuration options to pass on to nodemailer-smtp-transport. See their documentation for details.
smtpPort {Number} The port on we will attempt to connect to.

Component Invokers

  • mailOptions: {Object} The mail options to pass on to nodemailer-smtp-transport. The full syntax available can be found in the nodemailer documentation. See below for an example.
  • Returns: Nothing.

Send a message using nodemailer-smtp-transport. Fires onSuccess if the message is sent succesfully, or onError if the message fails. Here is an example of typical mailOptions:

  from:    "",
  to:      "",
  cc:      "",
  subject: "Sample subject...",
  text:    "Text body of the message.\n",
  html:    "<p>HTML body of the message.</p>\n"

Note that the to and cc elements can also be passed an array of email addresses.


A fluid.test.testEnvironment that constructs an instance of gpii.test.mail.smtp when its constructServer event is fired. Intended for use with something like the gpii.test.mail.caseholder caseholder (see below).

Component Options

Option Type Description
port {Number} The port the SMTP server should listen on.


An instance of, which is a case holder that allows wiring in default "first steps" and "last steps" for each test. This grade includes the "startup" sequences for gpii.test.mail.environment, which launch the mail server, and then wait for it to finish starting up before continuing. If you need different startup steps, extend instead.

The only practical difference between this and a stock caseholder is that your tests should be stored in options.rawModules rather than options.modules.




Package Sidebar


npm i gpii-mail-test

Weekly Downloads






Unpacked Size

39.3 kB

Total Files


Last publish


  • amb26
  • the-t-in-rtf