from sentry.utils.email import MessageBuilder message = MessageBuilder() message.subject = "Example email" message.body = "Hello, this is an example email."
from sentry.utils.email import MessageBuilder message = MessageBuilder() message.subject = "Example email" message.add_html( """Hello
This is an example email with HTML content.
""" )
from sentry.utils.email import MessageBuilder with open("example.pdf", "rb") as f: pdf_data = f.read() message = MessageBuilder() message.subject = "Example email" message.add_attachment(pdf_data, "application/pdf", "example.pdf")In all of the above examples, the `MessageBuilder` object is created with default settings, then customized by setting its attributes (`subject`, `body`) or calling its methods (`add_html`, `add_attachment`) to add content. Finally, the message can be sent using a standard email library such as `smtplib`.