Mailosaur logo
Mailosaur logo

Testing with SMTP

Use Mailosaur as a dummy SMTP server to catch every email your product sends.

Available with any of the following plans, except where noted:

All plans

The benefits of testing with SMTP
A hashtag icon

Whilst you can always use your server’s wildcard domain to create an unlimited number of email addresses, it is sometimes better to just send directly to Mailosaur via SMTP.

Cheaper than sending via your Email Service Provider (ESP)
A hashtag icon

If you have thousands of emails to test each day, sending these via your usual ESP (e.g. SendGrid or Amazon SES) can be unnecessarily expensive, as you’ll pay for each email you send, regardless of whether it is simply for testing purposes or not.

Sending lots of test emails via your email service provider can also be slow, as ESPs will often queue up emails and send them out in batches.

Prevent development and staging environments sending to real customers
A hashtag icon

When connecting directly to Mailosaur, every email you send is captured, regardless of who the email is sent “to”. This is great for protecting yourself from accidentally sending emails to real customers.

Where do I find my SMTP credentials?
A hashtag icon

Each server has a unique username and password usable for SMTP. To get this:

  1. Log into the Mailosaur Dashboard.
  2. Navigate to the server you want to use.
  3. Click the Settings button
  4. Select Send via SMTP.
  5. Copy the credentials from this screen.

How do I send via SMTP?
A hashtag icon

You can use these code snippets to conditionally send directly to Mailosaur in your development and/or staging environments:

const nodemailer = require('nodemailer');

(async () => {
  const transport = nodemailer.createTransport({
    service: 'Mailosaur',
    auth: {
      user: 'SERVER_ID@mailosaur.net',
      pass: 'SMTP_PASSWORD'
    }
  });

  await transport.sendMail({
    subject: 'A test email',
    from: 'Our Company <from@example.com>',
    to: 'Test User <to@example.com>',
    html: '<p>Hello world.</p>',
    text: 'Hello world.'
  });
})();