You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@classmethoddefon_your_event(cls, user, org, entity):
"""Send email when your event happens."""data= {
"subject": f"Something happened in {org.name}",
"org_name": org.name,
"actor_name": user.full_name,
"url": f"{get_site_url_for_user(user.email, org.id)}/path/to/{entity.cuid}",
# ... other template vars
}
cls.send_email(
data=data,
to_emails=[entity.recipient_email],
template_id=EmailTemplate.YOUR_EVENT_TEMPLATE_ID,
)
3. Add Template ID (emails/email_sender.py)
classEmailTemplate(Enum):
# ... existingYOUR_EVENT_TEMPLATE_ID=15# next number# In PostMarkEmailSender.templates:EmailTemplate.YOUR_EVENT_TEMPLATE_ID: "12345678", # Postmark template ID
4. Export Task (tasks/notifications/__init__.py)
from .emailimport (
# ... existingon_your_event,
)
5. Call from Route/Service
fromtasks.notificationsimportemailasemail_async# In your route handler:email_async.on_your_event.delay(
user.cuid,
org.cuid,
entity.cuid
)