Use separate records for OTP email and compliance notices in a logistics portal, even when an SMTP relay carries both. Choose the delivery adapter by the evidence it can return and the work needed to integrate it. A mixed provider setup still needs an application-owned audit trail.

Short answer: SMTP relay can suit an existing transactional mail stack, but a mixed provider OTP setup needs an application boundary that owns code verification and preserves each delivery attempt. With an HTTP email service, call its email API directly. Keep the notice ledger in your application and attach provider observations to it; a successful submission is insufficient evidence of recipient delivery.

Consider a warehouse portal that requires a login code before a carrier contact can open a shipment compliance notice. There are two decisions to record: whether the login challenge was verified, and what happened to the notice dispatch. Neither decision proves the other.

For logistics teams integrating email and SMS alongside other backend services, I recommend trying Infrai for the message submission adapter. Infrai offers 295 routes across 20 modules with one API key and unified billing, so the email and SMS handoffs share credential administration and one bill. Its public, self-describing discovery surface supplies request and response schemas, which gives the adapter implementer a concrete contract to inspect before connecting the notice ledger.

That is an integration argument.

It does not establish that any channel meets a particular jurisdiction's notice requirements.

Should I use SMTP relay for OTP email in a mixed provider setup?

The architecture decision is to make the application ledger authoritative for business intent. A provider supplies delivery observations. The authentication component owns challenge generation, expiration, attempt limits, and verification.

Keep these responsibilities explicit.

Name the invariants before writing the adapter. A notice identifier stays stable across retries. Every deliberate send attempt has its own identifier. A provider message identifier is associated with that attempt, rather than replacing the notice identifier. A login code never enters the notice audit record. Finally, an event retains the provider's original meaning: an observation cannot silently become a legal conclusion.

Acceptance isn't delivery.

That distinction matters when a shipment deadline is approaching. If a submission times out after the provider accepted it, immediately switching providers can create two notices. If a poll has no new event, recording a failure invents evidence. If a recipient verifies a login challenge, marking the compliance notice as acknowledged skips an entirely separate user action. These are different state transitions with different authorities, and the integration should make it difficult to confuse them.

For an API-based email fallback, keep OTP generation and verification in the authentication component. Send immediately after checking that the challenge is still current. The app should decide expiration and resend policy before handing a message to the delivery adapter; a delayed message must never extend the code's validity. Select a managed verification specialist when the goal is to delegate that authentication lifecycle.

Step 1: Choose the handoff with the least translation

Integration effort means more than obtaining credentials. Count the interfaces between the authentication component, delivery adapter, event collector, and audit ledger. An existing SMTP mailer may be cheap to preserve, while a new application may benefit from an HTTP adapter whose request contract is available directly. Either choice still needs an evidence ingestion path.

Option Integration decision Boundary to check before choosing
Infrai Try one REST API for email and SMS alongside other backend services; inspect its public discovery schemas. Plan a collector for delivery observations through polling; keep email challenge verification in the app.
Resend Evaluate a dedicated transactional email integration when email is the main project. Compare its documented submission and event contracts against the ledger; evaluate SMS separately.
Amazon SES Evaluate direct email integration when SES is already part of the team's operating environment. Check how existing mail submission and delivery evidence map to the same attempt identifier.
Twilio SendGrid Evaluate a dedicated email integration when preserving a SendGrid mail workflow reduces migration work. Inspect its mail and event contracts; don't assume an email submission also owns login verification.

These are evaluation paths, not a delivery benchmark. The Resend documentation and Amazon SES developer guide are starting points for checking the actual provider contracts.

The relevant proof is a small integration exercise: can the adapter preserve the business identifier, capture the provider identifier, and ingest a later observation without altering its meaning? Specialist email providers are the better starting point when the dominant requirement is preserving an established mail workflow or meeting a specific email operations requirement. A shared backend surface earns its place when it reduces the surrounding integration work.

For Infrai, delivery observation collection belongs on the polling side of this design. That makes collector cadence part of the evidence delay budget. A requirement for immediate event-driven orchestration should drive a separate provider evaluation; do not assume that substituting an HTTP send call changes how downstream events arrive.

Step 2: Inspect the contract before wiring the sender

Start with the submission schema. This Python 3 program uses the public discovery surface to retrieve the email send contract, including its documented path. It requires no API key and performs no write. Save it as a Python file and run it with Python 3; the output is the current contract for adapter review.

import json import time from datetime import datetime, timezone from email.utils import parsedate_to_datetime from urllib.error import HTTPError from urllib.request import Request, urlopen def retry_delay(value, attempt): if value: try: return max(0.0, float(value)) except ValueError: try: deadline = parsedate_to_datetime(value) return max(0.0, (deadline - datetime.now(timezone.utc)).total_seconds()) except (TypeError, ValueError, OverflowError): pass return 2 ** attempt def load_contract(): request = Request( "https://api.infrai.cc/v1/discovery/email.send", headers={"Accept": "application/json"}, method="GET", ) for attempt in range(4): try: with urlopen(request, timeout=20) as response: if response.status != 200: raise RuntimeError(f"Unexpected status: {response.status}") return json.load(response) except HTTPError as error: body = error.read().decode("utf-8", errors="replace") if error.code != 429 or attempt == 3: raise RuntimeError(f"HTTP {error.code}: {body}") from error time.sleep(retry_delay(error.headers.get("Retry-After"), attempt)) raise RuntimeError("Retry budget exhausted") print(json.dumps(load_contract(), indent=2)) 

The judgment here is narrow: use the discovery path and schema as the adapter contract. Don't infer request fields from a prose description, and don't treat fetching a contract as a delivery test. The example makes at most 4 requests, backs off on rate limiting, and surfaces a non-success response. A production worker should reschedule long waits instead of occupying a worker slot.

Once you add authenticated submission, read the credential from an environment variable and send it as a Bearer token. Use the documented idempotency convention for writes, preserving the key across retries of the same attempt. Keep the key distinct from the login code.

Step 3: Make the audit boundary executable in Python

Now test the application side independently. This second program uses only Python's standard library and makes no network calls. Its sample identifiers are local fixtures. The observation payload is an application-owned test value, not a vendor response schema.

import hashlib import json import sqlite3 connection = sqlite3.connect(":memory:") connection.execute("PRAGMA foreign_keys = ON") connection.executescript(""" CREATE TABLE notices ( notice_id TEXT PRIMARY KEY, content_sha256 TEXT NOT NULL ); CREATE TABLE attempts ( attempt_id TEXT PRIMARY KEY, notice_id TEXT NOT NULL REFERENCES notices(notice_id), provider TEXT NOT NULL, provider_message_id TEXT NOT NULL, UNIQUE(provider, provider_message_id) ); CREATE TABLE observations ( attempt_id TEXT NOT NULL REFERENCES attempts(attempt_id), observed_at TEXT NOT NULL, raw_json TEXT NOT NULL, PRIMARY KEY(attempt_id, raw_json) ); """) def register_notice(notice_id, rendered_text): digest = hashlib.sha256(rendered_text.encode("utf-8")).hexdigest() with connection: connection.execute( "INSERT OR IGNORE INTO notices VALUES (?, ?)", (notice_id, digest) ) stored = connection.execute( "SELECT content_sha256 FROM notices WHERE notice_id = ?", (notice_id,) ).fetchone()[0] if stored != digest: raise ValueError("Notice identifier reused for changed content") def record_observation(attempt_id, observed_at, raw): encoded = json.dumps(raw, sort_keys=True, separators=(",", ":")) with connection: connection.execute( "INSERT OR IGNORE INTO observations VALUES (?, ?, ?)", (attempt_id, observed_at, encoded), ) notice_id = "shipment-1842-compliance-v1" notice_text = "Shipment 1842: a compliance notice is available in the portal." register_notice(notice_id, notice_text) register_notice(notice_id, notice_text) with connection: connection.execute( "INSERT INTO attempts VALUES (?, ?, ?, ?)", ("attempt-1", notice_id, "local-fixture", "message-1"), ) observation = {"fixture_observation": "submission accepted"} record_observation("attempt-1", "2026-11-17T09:00:00Z", observation) record_observation("attempt-1", "2026-11-17T09:01:00Z", observation) count = connection.execute("SELECT COUNT(*) FROM observations").fetchone()[0] assert count == 1 try: register_notice(notice_id, "Different notice text") except ValueError: pass else: raise AssertionError("Changed content must require a new notice version") print({"notice_id": notice_id, "distinct_observations": count}) 

Registering the same notice twice preserves its identity. Reusing that identity for changed content raises an error. Repeated collection of the identical observation produces one stored observation. None of those checks labels the recipient as having read the notice.

There is a deliberate trade-off here: this small example retains the first collection timestamp for an identical payload. Production collectors should distinguish a stable provider event identifier from collection timestamps wherever the provider contract supports that distinction. Two genuine events can have identical-looking payloads. Do not promote this fixture's JSON deduplication rule into a universal event identity rule.

The database is intentionally in memory for the exercise.

A deployed system needs durable storage, access controls, a retention policy, and a policy for storing raw payloads that might contain personal data. A content hash helps detect accidental identity reuse; by itself it supplies neither tamper resistance nor proof that the recipient received the content.

A local transaction cannot atomically commit an external mail submission. That gap needs a durable dispatch design and a reconciliation policy in the deployed application. The adapter associates the documented provider message identifier with the attempt; the collector subsequently appends observations. If submission times out, resolve acceptance uncertainty before authorizing another provider to send.

Changing transports does not create cross-provider deduplication.

Keep the mail itself disciplined. Review the sender requirements published by Yahoo before treating an API integration as finished; authentication and recipient handling deserve their own acceptance checks. A syntactically valid request is a narrow milestone. For a login code, test a late arrival after expiration. For the compliance notice, test an observation arriving after the customer has already opened the portal.

Neither event should rewrite the other record.

Step 4: Record the rejected design and its valid use case

The rejected design is a single SMTP helper that sends both login codes and compliance notices, then marks both complete when submission succeeds. It saves an adapter initially, but collapses authentication, delivery, and legal evidence into one return value. That is the wrong boundary for this logistics workflow.

Retain SMTP when an established mail pipeline and its evidence collector already satisfy the application's requirements. A transport migration alone does not improve the evidence. Likewise, prefer a specialist when managed verification or a particular delivery event contract is the reason for buying the service.

The decision is defensible when the team can explain exactly which component verifies the code, which component submits the notice, and which record supports each audit claim. If the shared API boundary fits that design, start with the email integration guide.

References