To get started with Mailstack, you first need to create an account. The easiest way to do this is by registering using social authentication through Google, LinkedIn, or GitHub. Alternatively, you can use the standard registration form.
Once your account is successfully created, we will prepare a default mailbox and an API key for you. This default API key will be authorized to access the default mailbox.
From the console, you can create an unlimited number of new mailboxes and API keys. For each API key, you should specify the mailboxes that can be accessed with that key.
Additionally, you will be able to create virtual MFA (Multi-Factor Authentication) devices that function like Google Authenticator or similar apps. You can enter a QR code, and our API will generate and provide the OTP code, allowing you to automate your tests or RPA processes.
You can send your test emails to:
{tag}.{mailboxid}@mailstack.expandtesting.com
If the mailbox ID is b301a2
, the following email addresses are valid:
You can now use our free REST API to retrieve received emails. You can also use the
realtime
query parameter to wait for new incoming emails for a specified mailbox.
The API endpoint format is:
https://mailstack.expandtesting.com/api/query?apikey={apikey}&mailbox={mailbox}
You can get the values of apikey
and mailbox
from the console.
You can also search for a specific tag filter by adding the tag as a query parameter.
Let me give you an example:
Given this email address: contact.b301a2@mailstack.expandtesting.com
If you want to retrieve emails sent to the 'contact' tag and the b301a2
mailbox, you can
use this request:
https://mailstack.expandtesting.com/api/query?apikey=96e33757f23a91&mailbox=b301a2&tag=contactIn addition to the previous filter, you can also apply a date filter (unix timestamp) by using from_timestamp and to_timestamp in your query. Look at this example:
https://mailstack.expandtesting.com/api/query?apikey=96e33757f23a91&mailbox=b301a2&from_timestamp=1697836800000&to_timestamp=1697923200000You can use the from_timestamp and to_timestamp filters together or only one of them
https://mailstack.expandtesting.com/api/query?apikey=96e33757f23a91&mailbox=b301a2
This works with any HTTP client, even your browser! If you’re uncomfortable using the API key as a query parameter, you can also include it in your request headers.
The API will return the result as a JSON object. Here are some key concepts:
realtime
query parameter, the API will respond immediately and will not
wait for new incoming emails.realtime
query parameter, the API will wait for new incoming mail if no
results match the specified search criteria.realtime
mode, you don’t need to recall the API or make polling requests. After
1 minute of waiting, the API will return a 307 HTTP redirect to itself, so your client will
automatically resend the same request.realtime
.In the MailStack API, you can delete emails associated with a mailbox or delete a specific email by its ID. This section outlines how to perform these deletion operations and the expected responses.
To delete all emails associated with a specific mailbox, send a DELETE
request
to the following endpoint:
DELETE https://mailstack.expandtesting.com/api/mailboxes/{mailbox}/emails?apikey={apikey}
headers: { "apikey": "your_api_key" }
DELETE https://mailstack.expandtesting.com/api/mailboxes/b301a2/emails?apikey=your_api_key
DELETE https://mailstack.expandtesting.com/api/mailboxes/b301a2/emails
{
"headers": { "apikey": "your_api_key" }
}
{
"result": "success",
"message": "All emails associated with the mailbox [b301a2] have been deleted."
}
If there’s an error, you may receive:
{
"result": "fail",
"message": "An error occurred while deleting emails."
}
To delete a specific email by its ID, use the following endpoint:
DELETE https://mailstack.expandtesting.com/api/mailboxes/{mailbox}/emails/{emailid}?apikey={apikey}
DELETE https://mailstack.expandtesting.com/api/mailboxes/b301a2/emails/abc123?apikey=your_api_key
DELETE https://mailstack.expandtesting.com/api/mailboxes/b301a2/emails/abc123
{
"headers": { "apikey": "your_api_key" }
}
{
"result": "success",
"message": "Email deleted successfully."
}
If the email ID is not found, you may receive:
{
"result": "fail",
"message": "Email not found."
}
In case of an error:
{
"result": "fail",
"message": "An error occurred while deleting emails."
}
Our API offers the possibility to create virtual MFA devices that act like Google Authenticator, Microsoft Authenticator, and compatible tools, exposing the OTP code over a secure API. You can create a virtual device by scanning a QR code or entering the secret manually. After creating and associating an API key, you will be able to use our free API to generate the OTP.
This can be really helpful for automated end-to-end testing of our RPA processes, ensuring that your tests will not be broken due to multi-factor authentication.
Once the virtual device is created, you can use our API by calling this endpoint:
https://mailstack.expandtesting.com/api/mfa/otp?apikey={apikey}&deviceid={deviceid}
Here, apikey
is the API access key that can be created from the console, and
deviceid
is the ID for your virtual device, which can also be created there.
Here’s an example of the endpoint:
https://mailstack.expandtesting.com/api/mfa/otp?apikey=3d1ff0e394089b76bb887&deviceid=8446c7
You can use this API with any HTTP client or automated testing tools like Cypress, Playwright, and similar tools.
This is the alpha version, and new capabilities will come in future releases. Some features may not work as expected, so don’t hesitate to share your feedback by email or via LinkedIn.