Skip to main content
# Mailosaur Python client library

Mailosaur allows you to automate tests that require email. You can also use it for manual testing as it gives you unlimited test email addresses or use it as a fake/dummy SMTP service.

For more info go to [mailosaur.com](https://mailosaur.com/)


## Installation

pip install mailosaur

## Usage
```python
from mailosaur.mailosaur import Mailosaur
from unittest import TestCase

mailbox = Mailosaur(mailbox_id, api_key)

emails = mailbox.get_emails_by_recipient('anything.1eaaeef6@mailosaur.in')

assertEqual('something', emails[0].subject, 'The subject should be something')
```
##Api

*functions:*

- **Email[] get_emails(search_pattern)** - Retrieves all emails which have the searchPattern text in their body or subject.

- **Email[] get_emails_by_recipient(recipientEmail)** -
Retrieves all emails sent to the given recipient.

- **Email get_email(email_id)** -
Retrieves the email with the given id.

- **delete_all_email()** -
Deletes all emails in a mailbox.

- **delete_email(email_id)** -
Deletes the email with the given id.

- **get_attachment(attachment_id)** -
Retrieves the attachment with specified id as a byte array.

- **get_raw_email(raw_id)** -
Retrieves the complete raw EML file for the rawId given as a byte array. raw_id is a property on the email object.

- **generate_email_address()** -
Generates a random email address which can be used to send emails into the mailbox.

*structures*

- **Email** - The core object returned by the Mailosaur API
- **id** - The email identifier
- **creation_date** - The date your email was received by Mailosaur
- **sender_host** - The host name of the machine that sent the email
- **raw_id** - Reference for raw email data
- **html** - The HTML content of the email
- **links** - All links found within the HTML content of the email
- **images** - All images found within the HTML content of the email
- **body** - Unescaped HTML body of the email
- **text** - The text content of the email
- **links** - All links found within the text content of the email
- **body** - Text body of the email
- **headers** - Contains all email headers as object properties
- **subject** - Email subject
- **priority** - Email priority
- **from** - Details of email sender(s)
- **address** - Email address
- **name** - Email sender name
- **to** - Details of email recipient(s)
- **address** - Email address
- **name** - Email recipient name
- **attachments** - Details of any attachments found within the email
- **id** - Attachment identifier
- **file_name** - Attachment file name
- **length** - Attachment file size (in bytes)
- **content_type** - Attachment mime type (e.g. "image/png")

Release files for mailosaur 3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mailosaur 3.0
File Size Uploaded
mailosaur-3.0.tar.gz 4.2 kB Details

Release files / mailosaur-3.0.tar.gz

Download URL mailosaur-3.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
22965e45cb4c1be48a3137961426982d9bb7e81f77592835aa8b6e4770c598f9
BLAKE2b-256 checksum
How to use checksums
f2ed1a24b3fd07d5fe0b00ad5eeca3764b9f6b958895be4d01a606997df2949e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

8.1.1

2 release files

8.1.0

2 release files

8.0.0

2 release files

7.18.0

2 release files

7.17.1

2 release files

7.16.0

2 release files

7.15.0

2 release files

7.14.0

2 release files

7.12.0

2 release files

7.11.0

2 release files

7.9.0

2 release files

7.8.0

2 release files

7.7.0

2 release files

7.6.0

2 release files

7.5.0

2 release files

7.4.0

2 release files

7.3.1

2 release files

7.3.0

2 release files

7.2.1

2 release files

7.2.0

2 release files

7.1.0

2 release files

7.0.4

2 release files

7.0.3

2 release files

7.0.2

2 release files

7.0.1

2 release files

6.0.5

2 release files

6.0.4

2 release files

6.0.3

1 release file

6.0.2

1 release file

6.0.1

1 release file

6.0.0

1 release file

5.0.6

1 release file

5.0.5

1 release file

5.0.4

1 release file

5.0.2

1 release file

3.0.4

1 release file

3.0.3

1 release file

3.0.2

1 release file

3.0.1

1 release file

This release

3.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page