Skip to main content

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.

  1. A view is created
  2. The view is submitted as part of a PendingMail Command via the entity
  3. Entity checks whether the e-mail has already been delivered
  4. If it's a new e-mail a EmailCreated event is emitted
  5. Email Listener picks up EmailCreated event off the topic
  6. Email Listener submits email to Sendgrid via an API request
  7. 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.