Mailboxes and Email

Mailosaur provides a simple RESTful API for testing with emails.


Authentication & Mailbox ID

This document refers to YOUR_API_KEY and BOX_ID throughout.
For information on API keys, please refer to Authentication.
The value for BOX_ID can be found by looking your mailbox in the UI. You’ll see “Mailbox ID” in the top-left:

Mailbox ID shown in the Product

 

List all email

Returns a list of emails in this mailbox. The email returned is sorted by receipt date, with the most recent email appearing first.

curl https://mailosaur.com/api/mailboxes/BOX_ID/emails
-u YOUR_API_KEY:
require 'mailosaur'
mailbox = Mailosaur.new("BOX_ID", "YOUR_API_KEY")
emails = mailbox.get_emails
var Mailosaur = require("mailosaur")("YOUR_API_KEY");
var mailbox = new Mailosaur.Mailbox("BOX_ID");

mailbox.getEmails(function(err, emails) {
// asynchronously called
});
from mailosaur.mailosaur import Mailosaur
mailbox = Mailosaur("BOX_ID", "YOUR_API_KEY")
emails = mailbox.get_emails()
// Contact support@mailosaur.com
// Contact support@mailosaur.com
MailboxApi mailbox =
new MailboxApi("BOX_ID", "YOUR_API_KEY");
Email[] emails = mailbox.getEmails();
var mailbox = new MailboxApi("BOX_ID", "YOUR_API_KEY");
var emails = mailbox.GetEmails();

List email by recipient

You’ll usually know what address you send a mail to. You can use this information to return matches of that address:

curl https://mailosaur.com/api/mailboxes/BOX_ID/emails?recipient=jo@abc.com
-u YOUR_API_KEY:
require 'mailosaur'
mailbox = Mailosaur.new("BOX_ID", "YOUR_API_KEY")
emails = mailbox.get_emails_by_recipient("jo@abc.com")
var Mailosaur = require("mailosaur")("YOUR_API_KEY");
var mailbox = new Mailosaur.Mailbox("BOX_ID");
mailbox.getEmailsByRecipient("jo@abc.com", function(err, emails) {
// asynchronously called
});
from mailosaur.mailosaur import Mailosaur
mailbox = Mailosaur("BOX_ID", "YOUR_API_KEY")
emails = mailbox.get_emails_by_recipient("jo@abc.com")
// Contact support@mailosaur.com
// Contact support@mailosaur.com
MailboxApi mailbox =
new MailboxApi("BOX_ID", "YOUR_API_KEY");
Email[] emails = mailbox.getEmailsByRecipient("jo@abc.com");
var mailbox = new MailboxApi("BOX_ID", "YOUR_API_KEY");
var emails = mailbox.GetEmailsByRecipient("jo@abc.com");

These examples show you how to fetch all email where the body or subject matches the search pattern provided.

We’re using the search pattern of “Signup” for these examples:

curl https://mailosaur.com/api/mailboxes/BOX_ID/emails?search=Signup
-u YOUR_API_KEY:
require 'mailosaur'
mailbox = Mailosaur.new("BOX_ID", "YOUR_API_KEY")
emails = mailbox.get_emails("Signup")
var Mailosaur = require("mailosaur")("YOUR_API_KEY");
var mailbox = new Mailosaur.Mailbox("BOX_ID");
mailbox.getEmailsByRecipient("Signup", function(err, emails) {
// asynchronously called
});
from mailosaur.mailosaur import Mailosaur
mailbox = Mailosaur("BOX_ID", "YOUR_API_KEY")
emails = mailbox.get_emails("Signup")
// Contact support@mailosaur.com
// Contact support@mailosaur.com
MailboxApi mailbox =
new MailboxApi("BOX_ID", "YOUR_API_KEY");
Email[] file = emails = mailbox.getEmails("Signup");
var mailbox = new MailboxApi("BOX_ID", "YOUR_API_KEY");
var emails = mailbox.GetEmails("Signup");

Download attachment

Downloads an attachment.

curl https://mailosaur.com/api/attachments/ID
-u YOUR_API_KEY:
require 'mailosaur'
mailbox = Mailosaur.new("BOX_ID", "YOUR_API_KEY")
file = mailbox.get_attachment("ID")
var Mailosaur = require("mailosaur")("YOUR_API_KEY");
var mailbox = new Mailosaur.Mailbox("BOX_ID");
mailbox.getAttachment("ID", function(err, attachment) {
// asynchronously called
});
from mailosaur.mailosaur import Mailosaur
mailbox = Mailosaur("BOX_ID", "YOUR_API_KEY")
file = mailbox.get_attachment("ID")
// Contact support@mailosaur.com
// Contact support@mailosaur.com
MailboxApi mailbox =
new MailboxApi("BOX_ID", "YOUR_API_KEY");
Byte[] file = mailbox.getAttachment("ID");
var mailbox = new MailboxApi("BOX_ID", "YOUR_API_KEY");
var file = mailbox.GetAttachment("ID");

Download EML

Downloads an EML file.

curl https://mailosaur.com/api/raw/ID
-u YOUR_API_KEY:
require 'mailosaur'
mailbox = Mailosaur.new("BOX_ID", "YOUR_API_KEY")
file = mailbox.get_raw_email("ID")
var Mailosaur = require("mailosaur")("YOUR_API_KEY");
var mailbox = new Mailosaur.Mailbox("BOX_ID");
mailbox.getRawEmail("ID", function(err, attachment) {
// asynchronously called
});
from mailosaur.mailosaur import Mailosaur
mailbox = Mailosaur("BOX_ID", "YOUR_API_KEY")
file = mailbox.get_raw_email("ID")
// Contact support@mailosaur.com
// Contact support@mailosaur.com
MailboxApi mailbox =
new MailboxApi("BOX_ID", "YOUR_API_KEY");
Byte[] file = mailbox.getRawEmail("ID");
var mailbox = new MailboxApi("BOX_ID", "YOUR_API_KEY");
var file = mailbox.GetRawEmail("ID");

Delete an email

Permanently deletes an individual email. This cannot be undone.

curl https://mailosaur.com/api/emails/ID
-u YOUR_API_KEY:
-X DELETE
require 'mailosaur'
mailbox = Mailosaur.new("BOX_ID", "YOUR_API_KEY")
mailbox.delete_email("ID")
var Mailosaur = require("mailosaur")("YOUR_API_KEY");
var mailbox = new Mailosaur.Mailbox("BOX_ID");
mailbox.deleteEmail("ID", function(err) {
// asynchronously called
});
from mailosaur.mailosaur import Mailosaur
mailbox = Mailosaur("BOX_ID", "YOUR_API_KEY")
mailbox.delete_email("ID")
// Contact support@mailosaur.com
// Contact support@mailosaur.com
MailboxApi mailbox =
new MailboxApi("BOX_ID", "YOUR_API_KEY");
mailbox.deleteEmail("ID");
var mailbox = new MailboxApi("BOX_ID", "YOUR_API_KEY");
mailbox.DeleteEmail("ID");

Empty mailbox

Permanently deletes all email in the specified mailbox. This cannot be undone.

curl https://mailosaur.com/api/mailboxes/BOX_ID/empty
-u YOUR_API_KEY:
-X POST
require 'mailosaur'
mailbox = Mailosaur.new("BOX_ID", "YOUR_API_KEY")
mailbox.delete_all_emails
var Mailosaur = require("mailosaur")("YOUR_API_KEY");
var mailbox = new Mailosaur.Mailbox("BOX_ID");
mailbox.deleteAllEmail();
from mailosaur.mailosaur import Mailosaur
mailbox = Mailosaur("BOX_ID", "YOUR_API_KEY")
mailbox.delete_all_email()
// Contact support@mailosaur.com
// Contact support@mailosaur.com
MailboxApi mailbox =
new MailboxApi("BOX_ID", "YOUR_API_KEY");
mailbox.deleteAllEmail();
var mailbox = new MailboxApi("BOX_ID", "YOUR_API_KEY");
mailbox.DeleteAllEmail();