Facteur and Mailtrap
Mailtrap offers a fake SMTP server, the Email Sandbox. Here is what it publishes, then what Facteur does.
What Mailtrap publishes
Each line is something Mailtrap publishes. It carries the address of the page where we read it and the date we read it. What we could not check is not here. These pages change: read the source again before you decide.
-
01
Mailtrap's Email Sandbox describes itself as a fake SMTP server that traps all emails sent from your application. Each sandbox has its own SMTP credentials.
-
02
Mailtrap publishes SDKs for Node.js and TypeScript, PHP, Python, Ruby, Java, Go and .NET.
-
03
The sandbox shows HTML and text previews of emails, validates the HTML and scores spam risk with SpamAssassin.
-
04
The free Email Sandbox plan shows $0 per month, 50 test emails, 1 sandbox and 1 user.
-
05
Three paid Email Sandbox plans are shown with annual billing: Basic at $14 per month (500 test emails, 1 sandbox, 3 users), Team at $34 (5,000 emails, 5 sandboxes, 5 users) and Business at $99 (50,000 emails, 50 sandboxes, 50 users).
-
06
The official example of the mailtrap Node client builds new MailtrapClient({ token, testInboxId, accountId }), lists the messages of a test inbox with client.testing.messages.get(inboxId), then reads a message with getTextMessage(inboxId, messageId) or getHtmlMessage(inboxId, messageId).
https://github.com/mailtrap/mailtrap-nodejs/blob/main/examples/testing/messages.ts ·
The same test, with one then the other
Mailtrap's client lists the messages of a test inbox, then asks for the text of one. At Facteur, a single call waits for the matching message and returns it with its code already extracted.
const { MailtrapClient } = require('mailtrap');
const client = new MailtrapClient({ token, testInboxId: inboxId, accountId });
// The list of the test inbox's messages, then the text of the first one.
const messages = await client.testing.messages.get(inboxId);
const text = await client.testing.messages.getTextMessage(inboxId, messages[0].id);
// The code is still to be found in text.
// No Facteur package to install: one HTTP call that waits.
const search = new URLSearchParams({
inbox: 'j3k9x2mq',
sentTo: address,
wait: '30000',
});
const response = await fetch('https://api.facteur.eu/v1/messages?' + search, {
headers: { authorization: 'Bearer ' + process.env.FACTEUR_API_KEY },
});
const { messages } = await response.json();
// The code is already extracted, in a field of its own.
const code = messages[0].otp;
Four steps, both services side by side
-
Step 01
Create an account and an inbox
Each inbox has its own domain, and any address ending with it is accepted from the first message. There is nothing else to set up.
-
Step 02
Point the sends at the inbox
Where Mailtrap captures your application's SMTP traffic, your scenarios now write to an address of the inbox: the message follows the real sending path, the one a user will see.
-
Step 03
Replace the calls in the tests
Listing the messages and reading the text become a single search, which waits for the message and returns the body, the links and the code already extracted.
-
Step 04
Run the suite, then cancel
Keep both accounts until the suite is green: there is no data to export and no DNS to switch.
What changes, row by row
Each cell about Mailtrap links to the sentence of the sources it comes from. A row that no source lets us write is not in the table.
| Topic | Facteur | Mailtrap |
|---|---|---|
| Reception | Your application writes to an address of the inbox, as it would write to a person. | A fake SMTP server intercepts the emails your application sends. source |
| Waiting for a message | The search waits for the message on the server side, five minutes at most. | The official example lists the inbox's messages, then reads the text of one. source |
| Rendering and spam | No rendering preview, no HTML validation, no spam score. | HTML and text previews, HTML validation, SpamAssassin spam score. source |
| Libraries | No library published: an HTTP call, from any language. | Kits for Node.js and TypeScript, PHP, Python, Ruby, Java, Go and .NET. source |
| Number of inboxes | The number of inboxes depends on the plan: the Pricing page gives it. | The number of sandboxes depends on the plan. source |
What Facteur does
These lines describe Facteur as its product pages and help centre give it.
One address per test
Everything before the at sign is free. Two tests writing to inscription+run-42 and inscription+run-43 each get their own message, in the same inbox.
Wait for the message in one request
The search accepts a wait of five minutes at most. If nothing arrives, it answers an empty list, not an error.
The code, already extracted
The otp field holds the most likely one-time code. When nothing announces it, Facteur leaves it empty rather than guess.
Reading costs nothing
Only a received, kept message counts against your plan. A test that receives 3 emails and reads them 40 times uses 3.
Deleted when its time is up
Each message is deleted when your plan's duration has passed, with its raw file and attachments.
Hosted at OVHcloud
The application and its database are hosted at OVHcloud, and billing is in euros. The data centre is in France.
SMS are not received yet
The connection to the carrier that delivers SMS is not in service. An assigned number receives no real SMS today.
Frequently asked questions
When to look at Mailtrap?
Mailtrap publishes HTML previews, HTML validation and a spam score. Facteur's documentation describes none of these. If your test checks how an email renders more than what it contains, look at Mailtrap.
How much work is the migration from Mailtrap?
Mechanical work: replace the client, write to the inbox's addresses instead of the SMTP capture, drop the two-step read. There is no data to move and no DNS to switch, and the migration goes file by file.
What happens to the messages already received at Mailtrap?
They stay at Mailtrap. They are test data: they come back on the next run of your suite, there is nothing to export.
Where are Facteur's prices?
On the Pricing page, which reads Facteur's grid. No Facteur price is written here.
The other tools
The same approach for each tool: what it publishes, sourced and dated, then what Facteur does.
Facteur and Mailisk
What Mailisk publishes about its namespaces, its SMS and its free plan, and what Facteur does.
Facteur and MailSlurp
What MailSlurp publishes about its plans, inboxes and phone numbers, and what Facteur does.
Facteur and Mailpit
What Mailpit publishes about its open source software, SMTP server and API, and what Facteur does.
Facteur and Mailosaur
What Mailosaur publishes about its plans, its daily limit, its SMS and its API, and what Facteur does.
Migrate from Mailosaur
The mapping of the API calls, one by one, and the ones that have no equivalent at Facteur.
Try Facteur without an account
The trial receives a test email, with no sign-up. Prices are on the Pricing page.