Description
We used to send emails from {user}@{client}.lokole.ca
. Due to a change in Sendgrid, we had to change this to {user}-{client}@lokole.ca
with a reply-to header set to {user}@{client}.lokole.ca
so that our inbound email parsing/dispatch logic didn't have to change. See this code comment:
lokole/opwen_email_server/services/sendgrid.py
Lines 103 to 109 in 55c47f8
This, of course, is a hack and brittle as if someone replies directly to {user}-{client}@lokole.ca
, the email never reaches the user.
This here task is about fixing the issue. What needs to be done is fairly straight forward:
-
Add a registration in Sendgrid so that any email sent to
lokole.ca
is routed to one of our webhook endpoints. Also set up the MX records in Cloudflare so thatlokole.ca
points to Sendgrid. The code for this already exists: we can re-use the register_client code just with some small modifications as the code currently assumes that we register an endpoint like{client}.lokole.ca
and now we want to register the endpointlokole.ca
. -
Add a request receiver that listens to the new webhook and that parses the email and modifies
{user}-{client}.lokole.ca
to{user}@{client}.lokole.ca
and triggers the downstream email ingestion flow. The code for this already exists in email_receive and just needs to be adapted to have the pre-processing step which normalizes the email from the hack/workaround format{user}-{client}.lokole.ca
to the format we previously used{user}@{client}.lokole.ca
.