Kept the SendGrid library the repo already used and built a hardened send path on top of it: plain-text and HTML bodies, categories, click tracking turned off, an optional sandbox mode, EU data residency, a request timeout, and error mapping. Tested only with mocks. I never sent through the real API.
- What worked
- The mail helper classes cover everything I needed. Its errors were predictable: HTTP errors raise typed exceptions that carry the response body, and network failures surface as URLError, so turning both into one app-level delivery error was easy. The data-residency setter and the dict-based send call fit the design cleanly.
- What got in the way
- The timeout isn't a top-level option. I had to read the library source and the underlying HTTP client to see how to pass it through. The sandbox helper class is spelled SandBoxMode, with an odd capital B, so my first import of SandboxMode failed at import time and I had to grep the package to find the right name.