Send emails fast and with confidence through our easy to use REST API interface.
This is the API interface to the Mail Baby Mail services provided by InterServer. To use this service you must have an account with us at my.interserver.net.
Every sending account in MailBaby is backed by a Mail Order — a provisioned sending credential with a numeric id and a corresponding SMTP username (mb<id>). Most calls accept an optional id parameter; when omitted the API automatically selects the first active order on your account. Use GET /mail to list all orders, and GET /mail/{id} to inspect a single order including its current SMTP password.
Three sending methods are available depending on your use-case:
| Endpoint | Best for | |----------|----------| | POST /mail/send | Simple single-recipient messages | | POST /mail/advsend | Multiple recipients, CC/BCC, attachments, named contacts | | POST /mail/rawsend | Pre-built RFC 822 messages (e.g. DKIM-signed payloads) |
After a successful send each endpoint returns a GenericResponse whose text field contains the transaction ID assigned by the relay. This ID can later be matched against entries in GET /mail/log via the mailid query parameter.
GET /mail/log provides paginated access to every message accepted by the relay for your account. Combine any of the query parameters to narrow results — e.g. from, to, subject, messageId, origin, mx, startDate/endDate, and delivered.
Two independent mechanisms exist for suppressing unwanted email:
- Block lists (
GET /mail/blocks,POST /mail/blocks/delete) — addresses flagged by the system spam filters (LOCAL_BL_RCPT / MBTRAP rules in rspamd, and suspicious subjects). - Deny rules (
GET /mail/rules,POST /mail/rules,DELETE /mail/rules/{ruleId}) — custom rules you configure to reject specific senders, domains, destination addresses, or subject-line prefixes before a message is even attempted.
In order to use most of the API calls you must pass credentials from the my.interserver.net site.
We support several different authentication methods but the preferred method is to use the API Key which you can get from the Account Security page.
Pass your key in the X-API-KEY HTTP request header for every protected call.
This Python package is automatically generated by the OpenAPI Generator project:
- API version: 1.4.0
- Package version: 1.0.0
- Generator version: 7.21.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit https://www.mail.baby/contact/
Python 3.9+
If the python package is hosted on a repository, you can install directly using:
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)
Then import the package:
import openapi_clientInstall via Setuptools.
python setup.py install --user(or sudo python setup.py install to install the package for all users)
Then import the package:
import openapi_clientExecute pytest to run the tests.
Please follow the installation procedure and then run the following:
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.mailbaby.net
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
host = "https://api.mailbaby.net"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'
# Enter a context with an instance of the API client
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = openapi_client.BlockingApi(api_client)
type = 'type_example' # str | The type of deny rule.
data = 'data_example' # str | The value to match against, interpreted according to `type`: a full email address for `email`/`destination`, a domain name for `domain`, or an alphanumeric prefix string for `startswith`.
user = 'user_example' # str | Optional SMTP username of the mail order to associate this rule with (e.g. `mb20682`). If omitted the first active order is used. Valid usernames are the `username` values returned by `GET /mail`. (optional)
try:
# Creates a new email deny rule
api_response = api_instance.add_rule(type, data, user=user)
print("The response of BlockingApi->add_rule:\n")
pprint(api_response)
except ApiException as e:
print("Exception when calling BlockingApi->add_rule: %s\n" % e)All URIs are relative to https://api.mailbaby.net
| Class | Method | HTTP request | Description |
|---|---|---|---|
| BlockingApi | add_rule | POST /mail/rules | Creates a new email deny rule |
| BlockingApi | delete_rule | DELETE /mail/rules/{ruleId} | Removes a deny mail rule |
| BlockingApi | delist_block | POST /mail/blocks/delete | Removes an email address from the block lists |
| BlockingApi | get_mail_blocks | GET /mail/blocks | Displays a list of blocked email addresses |
| BlockingApi | get_rules | GET /mail/rules | Displays a listing of deny email rules |
| HistoryApi | get_stats | GET /mail/stats | Account usage statistics |
| HistoryApi | view_mail_log | GET /mail/log | Displays the mail log |
| SendingApi | raw_mail | POST /mail/rawsend | Sends a raw RFC 822 email |
| SendingApi | send_adv_mail | POST /mail/advsend | Sends an Email with Advanced Options |
| SendingApi | send_mail | POST /mail/send | Sends an Email |
| ServicesApi | get_mail_order_by_id | GET /mail/{id} | Displays details for a single mail order |
| ServicesApi | get_mail_orders | GET /mail | Displays a list of mail service orders |
| StatusApi | ping_server | GET /ping | Checks if the server is running |
- DenyRuleNew
- DenyRuleRecord
- EmailAddressName
- EmailAddressNames
- EmailAddressParam
- EmailAddressTypes
- EmailAddressesTypes
- ErrorMessage
- GenericResponse
- MailAttachment
- MailBlockClickHouse
- MailBlockRspamd
- MailBlocks
- MailLog
- MailLogEntry
- MailOrder
- MailOrderDetail
- MailStatsType
- MailStatsVolume
- SendMail
- SendMailAdv
- SendMailRaw
- SendMailTo
Authentication schemes defined for the API:
- Type: API key
- API key parameter name: X-API-KEY
- Location: HTTP header