Skip to content

Don't rely on reply-to header #552

Open
@c-w

Description

@c-w

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions