Email Service
The e-mail service is reponsible for the delivery of e-mails within the reOS system. As such it listens to all services to compile and aggregate information. The templating/styling of e-mails can be founds in the repo: https://github.com/CastleOne/phoenix-emails
and it uses https://mdxjs.com
Current e-mails
- Agent
- Lease activation
- Lease draft notice
- Unpaid invoice notification
- Unreconciled payment notification
- Owner
- Lease activated
- Lease documentation
- Payment confirmation
- Payment late
- Tenant
- Lease activated
- Lease documentation
- Monthly invoice
- Payment late
- Payment received
- Payment reminder
- System
- Proof of payment
- Initial payment
- Landlord contact
- Password reset instructions
- Payment rejection
- Tenant contact
- Verify e-mail
Listeners
E-mails are delivered due to specific events picked up on the topic. They all follow the same formula apart from the Invoice Opened
event.
- A view is created
- The view is submitted as part of a PendingMail Command via the entity
- Entity checks whether the e-mail has already been delivered
- If it's a new e-mail a
EmailCreated
event is emitted - Email Listener picks up EmailCreated event off the topic
- Email Listener submits email to Sendgrid via an API request
- Email marked as submitted on Entity
sequenceDiagram
participant L as External Listener
participant EL as Email Listener
participant E as Entity
participant T as Topic
participant S as Sendgrid
note over L,T: Send an E-mail
L-->>L: Create a view
L->>E: Submit Email
alt new email
E->>L: Successful
E->>T: EmailCreated
else
E-->>L: Already delivered
end
T-->>EL: EmailCreated
EL->>+S: Send Email to Sendgrid
S->>-EL: Response
alt Response is 200 OK
EL->>E: Send Email
E->>E: SubmittedEmail
else Error
EL-->>EL: Log Error
end
Schedulers
Invoice Opened events are not immediately submitted, rather they are put into a queue and a scheduler processes, aggregates all invoices for a tenant and submits 1 email for the tenant.