-
Notifications
You must be signed in to change notification settings - Fork 8
Creating an Email
If you need to add a new email for some event, here's how you do it:
Create a .html
and a .txt
file of the same name in backend/grant/templates/emails/
. Both email's contents should match each other.
Add the email's parameters to backend/grant/email/send.py
. Copy one of the existing emails to see what's needed. Make sure the name of the parameter function / lookup key matches the file names you made in the previous step.
Add some example parameters in backend/grant/admin/example_emails.py
, and add an entry for the email in admin/src/components/Emails/emails.ts
. Test the email by going to http://localhost:3500/emails and clicking on your email.
Where you actually want the email to trigger a send, add the following:
from grant.email.send import send_email
# ...
send_email(to_email, 'email_id', {
'args': 'for',
'email': 'templates',
# ...
})
send_email
will handle everything about sending logic, and doesn't need to be try / catch'd. Make sure you actually run this and have the email sent to your inbox to confirm the way it looks.