Before you can send an email, you need to create an inbox.

Limits

  • 10MB total attachment size
  • 10 emails per day for the free tier, 1000 emails per day for the paid tiers

If you need higher limits, contact us to upgrade.

REST API

1. Create an Api Key (if you don’t already have one)

Create an api key by going to the api keys page. You can also click the Create Your First Api Key button in the sidebar or navigate to the api keys page by clicking Settings, under the user dropdown at the bottom of the sidebar.

Be sure to save the api key somewhere safe. You will not be able to see it later if you lose it.

Create Your First Api Key

User Settings

2. Send an Email

Make sure to pass the api_key you created in the previous step in the Authorization header. Also make sure to replace CREATED_INBOX_ID with the ID of the inbox you created in the previous step. And change the to_addresses to the email address you want to send the email to.

curl -X POST "https://api.botmailroom.com/email/send" \
     -H "Authorization: Bearer ${api_key}" \
     -H "Content-Type: application/json" \
     -d '{
       "inbox_id": CREATED_INBOX_ID,
       "subject": "Hello from Bot Mailroom",
       "plain_text": "Hello from Bot Mailroom. We are testing our email sending functionality.",
       "to_addresses": [
         {
           "address": "CHANGE_THIS@CHANGE_THIS.com",
           "name": null
         },
       ]
     }'

See the API Reference for more information on the request body.

Optional - Add an Attachment

Add an attachment to the attachment pool by sending a request to the add attachment to pool endpoint.

Make sure to pass the api_key you created in the previous step in the Authorization header. Also make sure to replace path/to/file with the path to the file you want to add to the attachment pool.

curl -X POST "https://api.botmailroom.com/email/add-attachment-to-pool" \
     -H "Authorization: Bearer ${api_key}" \
     -H "Content-Type: multipart/form-data" \
     -F "file=@path/to/file"

The response will contain the ID of the attachment, which you can then use in the send_email request.

curl -X POST "https://api.botmailroom.com/email/send" \
     -H "Authorization: Bearer ${api_key}" \
     -H "Content-Type: application/json" \
     -d '{
       "inbox_id": CREATED_INBOX_ID,
       "subject": "Hello from Bot Mailroom",
       "plain_text": "Hello from Bot Mailroom. We are testing our email sending functionality.",
       "to_addresses": [
         {
           "address": "CHANGE_THIS@CHANGE_THIS.com",
           "name": null
         },
       ],
       "attachment_ids": [
         ATTACHMENT_ID
       ]
     }'

Python Client

1. Create an Api Key (if you don’t already have one)

Create an api key by going to the api keys page. You can also click the Create Your First Api Key button in the sidebar or navigate to the api keys page by clicking Settings, under the user dropdown at the bottom of the sidebar.

Be sure to save the api key somewhere safe. You will not be able to see it later if you lose it.

Create Your First Api Key

User Settings

2. Install the Client (if you haven’t already)

pip install botmailroom

3. Initialize the Client

from botmailroom import BotMailRoom

client = BotMailRoom(api_key="your_api_key") # or set the BOTMAILROOM_API_KEY environment variable

4. Send an Email

Make sure to replace CREATED_INBOX_ID with the ID of the inbox you created in the previous step. And change the to_addresses to the email address you want to send the email to.

email_id = client.send_email(
    inbox_id=CREATED_INBOX_ID,
    subject="Hello from Bot Mailroom",
    to_addresses=[{"address": "CHANGE_THIS@CHANGE_THIS.com", "name": None}],
    plain_text="Hello from Bot Mailroom. We are testing our email sending functionality.",
)

See the API Reference for more information on the request body.

Optional - Add an Attachment

With the python client, you can just pass the file info directly to the send_email method and it will handle adding the attachment to the pool for you.

filename = "path/to/file"

with open(filename, "rb") as file:
    file_bytes = file.read()

attachment_raw = (file_bytes, filename.split("/")[-1], "application/pdf")

email_id = client.send_email(
    inbox_id=CREATED_INBOX_ID,
    subject="Hello from Bot Mailroom",
    to_addresses=[{"address": "CHANGE_THIS@CHANGE_THIS.com", "name": None}],
    plain_text="Hello from Bot Mailroom. We are testing our email sending functionality.",
    attachments_raw=[attachment_raw],
)