Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't rely on reply-to header #552

Open
c-w opened this issue Jun 12, 2021 · 0 comments
Open

Don't rely on reply-to header #552

c-w opened this issue Jun 12, 2021 · 0 comments

Comments

@c-w
Copy link
Member

c-w commented Jun 12, 2021

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:

# at some point SendGrid had the ability to send from subdomains of a verified
# domain, so verifying {domain} let us send from {client}.{domain}
# ...this feature went away so the following is a work-around which
# changes the from address to the verified root domain but using reply-to
# so that the email still gets routed back to the original client
# ...this is a pretty ugly hack and the real fix is to change the logic of
# how we sign up users on clients to use the new format {user}-{client}@{domain}

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 that lokole.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 endpoint lokole.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant