Skip to the documentation
Python

nextmail.senders

Every method in this namespace: its signature, its parameters, what it returns and an example.

Methods

What is known about the organisation behind a sender, the line the reading pane shows under an unfamiliar one, looking a sender up, and the picture shown for a sender.

senders.get()

Read what is known about a sender

Scopesthreads:read
Signature
def get(    email: str,    *,    api_key: str | None = None,    timeout: float | None = None,) -> SenderProfileResource

Returns a sentence or two about the organisation behind the domain of an address, the line the reading pane shows under an unfamiliar sender. Only the domain is read, so any address on it gives the same answer, a subdomain such as mail.stripe.com included, and domain names the organisation's own domain. What is known is shared by every workspace and looked up again by itself once it is 30 days old.

A domain nobody has looked up yet is a 404, and so are personal mailbox providers such as Gmail and the domains of your own workspace. Each raises NextmailApiError with is_not_found. research looks a domain up.

Parameters

emailstrRequired

An address of the sender, such as [email protected].

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises NextmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

SenderProfileResource, a dict with object set to 'sender_profile', domain, about, avatarUrl, avatarKind and updatedAt. avatarUrl is the picture the app shows for the address, or None when it draws initials, and avatarKind says where it comes from, one of SENDER_AVATAR_KINDS: member for the photo of somebody in the workspace or of one of its addresses or domains, contact for a contact photo, lookup for a picture found on Gravatar or the web, which get_avatar serves with the same credential, and generated for initials.

Example

from nextmail import NextmailApiError, nextmail try:    sender = nextmail.senders.get('[email protected]')    print(sender['domain'], sender['about'])except NextmailApiError as error:    if error.is_not_found:        print('Nobody has looked stripe.com up yet')    else:        raise

Notes

Also available in

API
GET /senders/{email}
TypeScript
senders.get()
Ruby
senders.get
PHP
senders->get
Go
Senders.Get
Java
senders().get
C#
Senders.GetAsync
CLI
nextmail senders get

senders.get_avatar()

Fetch the picture of a sender

Scopesthreads:read
Signature
def get_avatar(    email: str,    *,    api_key: str | None = None,    timeout: float | None = None,) -> bytes

Returns the picture Nextmail found for the address on Gravatar, in the BIMI logo of its domain or on the website of its domain, as the image itself: the one the app draws when nobody in the workspace and no contact has a photo for the sender. The response carries its type in Content-Type.

It is looked up the first time it is asked for and kept, so a picture not found yet can come a moment later. avatarUrl and avatarKind on get say which picture the app shows for the address, and a photo of a member, an address or a contact is served from a public URL instead.

Parameters

emailstrRequired

The address of the sender, such as [email protected].

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises NextmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

bytes holding the image.

Example

from pathlib import Path from nextmail import nextmail picture = nextmail.senders.get_avatar('[email protected]') Path('stripe.png').write_bytes(picture)

Notes

  • An address with no picture is a 404, and so is every address for an account that turned off looking up contact photos in its settings.

  • An account looks up at most 600 pictures an hour, and a picture already found is served without a lookup.

  • An address that is not one is a 422 invalid_parameter on email.

Also available in

API
GET /senders/{email}/avatar
TypeScript
senders.getAvatar()
Ruby
senders.get_avatar
PHP
senders->getAvatar
Go
Senders.GetAvatar
Java
senders().getAvatar
C#
Senders.GetAvatarAsync
CLI
nextmail senders get-avatar

senders.research()

Look a sender up

Scopesthreads:read
Signature
def research(    email: str,    *,    api_key: str | None = None,    timeout: float | None = None,) -> SenderProfileResource

Searches the web for the organisation behind the domain of an address and keeps what it found, as the reading pane does the first time it shows a sender. Every address under the domain shares the answer, a subdomain such as mail.stripe.com included, and it is kept for 30 days before it is looked up again, so a domain that was looked up before is answered from what was kept and nothing is searched. Personal mailbox providers such as Gmail and the domains of your own workspace are never looked up.

Only the owner of the workspace may look senders up, with a key or an app that is not limited to particular addresses or domains: anything else is a 422 capability_unsupported or a 403 owner_only. A workspace looks up at most 200 new domains a day, and the next one is a 429 research_limit_reached. A domain nothing could be found about, a personal mailbox provider and a domain of your own workspace are a 404.

Parameters

emailstrRequired

An address of the sender. Only its domain is looked up.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises NextmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

SenderProfileResource, what was found or what was already known, with avatarUrl and avatarKind as get returns them.

Example

from nextmail import nextmail sender = nextmail.senders.research('[email protected]') print(sender['domain'], sender['about'])

Notes

  • The SDK retries it after a network failure, which is safe because a domain that was found is answered from what was kept.

Also available in

API
POST /senders/{email}/research
TypeScript
senders.research()
Ruby
senders.research
PHP
senders->research
Go
Senders.Research
Java
senders().research
C#
Senders.ResearchAsync
CLI
nextmail senders research