from sentry.utils.email import MessageBuilder msg = MessageBuilder() msg.subject('New issue in project') msg.body('There is a new issue in your project, please check it.') msg.add_users(['[email protected]', '[email protected]']) msg.send()
from sentry.utils.email import MessageBuilder from sentry.models import User msg = MessageBuilder() msg.subject('Weekly report') msg.body('Here is your weekly report.') users = User.objects.filter(is_active=True) emails = [user.email for user in users] msg.add_users(emails) msg.send()In this example, we again create a new `MessageBuilder` object and set the subject and body of the email message. We also retrieve a list of active users from the `User` model in Sentry and get their email addresses. We then pass this list to `add_users` to add them as recipients. Finally, we call the `send` method to send the email. Overall, the `sentry.utils.email.MessageBuilder` package library provides a useful set of tools for building and sending email messages in Python.