Skip to main content

Deployments that send emails

You can use Modelbit's API to send emails from deployments. This is useful for quick, ad-hoc alerting when an expectation has been violated, e.g. an inference outside normal boundaries, or a batch size that's too large or too small.

To send an email, call mb.send_email:

subject = "My Subject Line"
to = ["", ""],
msg = "Body of the email"

All emails are sent from

Sending emails from Notebook-based deployments

Emails can be sent from the deploy functions of deployments deployed from Notebooks. For example:

from sklearn import linear_model
lm = linear_model.LinearRegression()[[1], [2], [3]], [2, 4, 6])

def example_doubler(half: int) -> int:
if type(half) is not int:
subject = "Invalid type sent to doubler!",
to = [""],
msg = f"Doubler received invalid type. Type was: {type(half)}"
return None

return round(lm.predict([[half]])[0])


Sending emails from git-based deployments

Emails can also be sent from any place in code checked and deployed via git. Simply place the mb.send_email line anywhere in your code.