Comparing email previews providers? Discover our new pricing options - chat to sales or book a demo to unlock your savings now
Email testingSMTP

Testing with SMTP

Send email directly to Mailosaur via SMTP to capture every message your product sends.

Why send via SMTP?

Each Mailosaur inbox has its own SMTP server. Pointing your application at this server means every email it sends is captured inside Mailosaur, regardless of the recipient address.

This is useful when you want to:

  • Avoid email service provider costs. Sending thousands of test emails through a provider such as SendGrid or Amazon SES adds unnecessary cost. Providers also queue messages and send them in batches, which slows delivery.
  • Prevent emails reaching real customers. In development and staging environments, connecting to Mailosaur ensures no email is accidentally delivered to an external recipient.

Find your SMTP credentials

Each inbox has a unique SMTP username and password. To view them:

  1. Navigate to the inbox you want to use.
  2. Click the Connect tab.
  3. Copy the SMTP credentials shown on screen.

For full connection details, including port numbers and security options, see SMTP, POP3, and IMAP connection details.

Send email via SMTP

The following examples show how to send email directly to Mailosaur. Replace SERVER_ID and SMTP_PASSWORD with the credentials from your inbox.

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.'
  });
})();
import smtplib

sender = "Our Company <from@example.com>"
recipient = "Test User <to@example.com>"

message = f"""\
Subject: A test email
To: {recipient}
From: {sender}

Hello world."""

with smtplib.SMTP("smtp.mailosaur.net", 2525) as server:
    server.login("SERVER_ID@mailosaur.net", "SMTP_PASSWORD")
    server.sendmail(sender, recipient, message)
// Uses javax.mail
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.mailosaur.net");
props.put("mail.smtp.port", "2525");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.ssl.protocols", "TLSv1.2");
props.put("mail.smtp.ssl.trust", "smtp.mailosaur.net");

Session session = Session.getInstance(props, new Authenticator() {
  @Override
  protected PasswordAuthentication getPasswordAuthentication() {
    return new PasswordAuthentication("SERVER_ID@mailosaur.net", "SMTP_PASSWORD");
  }
});

MimeMessage message = new MimeMessage(session);

message.setSubject("A test email");
message.setFrom(new InternetAddress("Our Company <from@example.com>"));
message.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress("Test User <to@example.com>"));

MimeBodyPart mimeBodyPart = new MimeBodyPart();
mimeBodyPart.setContent("<p>Hello world.</p>", "text/html; charset=utf-8");

Multipart multipart = new MimeMultipart();
multipart.addBodyPart(mimeBodyPart);

message.setContent(multipart);

session.getTransport("smtp").send(message);
using MimeKit;
using MailKit.Security;
using MimeKit.Text;

var message = new MimeMessage();
message.From.Add(new MailboxAddress("Our Company", "from@example.com"));
message.To.Add(new MailboxAddress("Test User", "to@example.com"));
message.Subject = "A test email";

message.Body = new TextPart(TextFormat.Html) {
  Text = "<p>Hello world.</p>"
};

using (var emailClient = new MailKit.Net.Smtp.SmtpClient()) {
  emailClient.Connect("smtp.mailosaur.net", 2525, SecureSocketOptions.StartTls)
  emailClient.Authenticate("SERVER_ID@mailosaur.net", "SMTP_PASSWORD");
  emailClient.Send(message);
  emailClient.Disconnect(true);
}
require 'net/smtp'

message = <<MESSAGE_END
From: Our Company <from@example.com>
To: Test User <to@example.com>
Subject: A test email

Hello world.
MESSAGE_END

Net::SMTP.start(
  'smtp.mailosaur.net',
  2525,
  'smtp.mailosaur.net',
  'SERVER_ID@mailosaur.net', 'SMTP_PASSWORD', :cram_md5
) do |smtp|
  smtp.send_message message, 'from@example.com', 'to@example.com'
end
// Install with `composer require nette/mail`
require_once('vendor/autoload.php');

$smtp = new Nette\Mail\SmtpMailer([
  'host' => 'smtp.mailosaur.net',
  'port' => 2525,
  'username' => 'SERVER_ID@mailosaur.net',
  'password' => 'SMTP_PASSWORD',
  'secure' => 'starttls',
]);

$message = new Nette\Mail\Message;
$message->setFrom('Our Company <from@example.com>')
  ->addTo('Test User <to@example.com>')
  ->setSubject('A test email')
  ->setHtmlBody('<p>Hello world.</p>');

$smtp->send($message);
import (
  "fmt"
  "log"
  "net/smtp"
)

func main() {
  from := "from@example.com"
  to := []string{
    "to@example.com",
  }
  msg := []byte("From: Our Company <from@example.com>\r\n" +
    "To: Test User <to@example.com>\r\n" +
    "Subject: A test email\r\n\r\n" +
    "Hello world.\r\n"
  )

  auth := smtp.CRAMMD5Auth("INBOX_ID@mailosaur.net", "SMTP_PASSWORD")
  err := smtp.SendMail("smtp.mailosaur.net:2525", auth, from, to, msg)
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println("Mail sent successfully!")
}