The benefits of testing with SMTP
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)
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
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?
Each server has a unique username and password usable for SMTP. To get this:
- Log into the Mailosaur Dashboard.
- Navigate to the server you want to use.
- Click the Settings button
- Select Send via SMTP.
- Copy the credentials from this screen.
How do I send via SMTP?
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.'
});
})();
Previous
Testing with POP3