Skip to main content

Python client library for Mailosaur

Project description

# 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")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mailosaur-3.0.2.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file mailosaur-3.0.2.tar.gz.

File metadata

  • Download URL: mailosaur-3.0.2.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mailosaur-3.0.2.tar.gz
Algorithm Hash digest
SHA256 f7c18897d7111a83201e740203e3c225917953863dd21aa3c32b533ac71ca951
MD5 e7b3117aa4501d13b7bce070a3ae6a87
BLAKE2b-256 9e7a4c40546112209a221a1304e0fe274c9ef9aa52ed02071b0bf24b5d2323ac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page