Migracja z Mailgun
Ta strona mapuje parametry POST /v3/{domain}/messages Mailgun, listy blokad i zdarzenia webhooków na Bird. Postępuj zgodnie z głównym przewodnikiem migracji po kolei i użyj tych mapowań w krokach 1, 3 i 4.
Przekaż to swojemu agentowi
Wklej to do Claude Code, Cursor lub Codex. Agent przetworzy tę stronę w kontekście Twojego repozytorium, korzystając z dowolnego interfejsu Bird, który już ma: serwera MCP, jeśli jest podłączony, lub CLI, jeśli jest zainstalowany i zalogowany.
Przykład kodu
I am moving an email integration from Mailgun to Bird. Route through it with me.
1. Check what you already have before setting anything up. If Bird's MCP server is connected, use its tools. If the Bird CLI is installed and signed in, use that. Either one is enough, and every step below is an action you take with whichever you have. Only if neither is present, follow https://bird.com/docs/ai/set-up-your-agent.md to set one up and sign me in. Every Bird docs page serves Markdown at its own URL with `.md` appended, so fetch that rather than the HTML.
2. Read https://bird.com/docs/guides/email/migrate/mailgun.md for the parameter, suppression and event mapping, and https://bird.com/docs/guides/email/migrate.md for the order the steps go in.
3. Find and list my Mailgun usage in this repository before you change anything: the /v3/{domain}/messages call sites and any SDK wrappers around them, every o:, v: and h: prefixed parameter I pass, my webhook handler and the URL it is registered at, and every Mailgun domain I send from. Mailgun scopes almost everything per domain, so keep that list of domains: the next two steps both work through it.
4. Register each of those sending domains with Bird and give me the DNS records to publish, following https://bird.com/docs/guides/email/sending-domains.md. Leave every DNS record Mailgun uses exactly as it is: Bird's records are published alongside them and both providers authenticate side by side until I switch traffic. Publishing DNS affects mail for the whole domain, so show me the records and let me publish them.
5. Export my suppressions from Mailgun and import them into Bird before any production traffic goes through Bird, so my first sends do not reach addresses that already bounced or complained. Mailgun keeps three lists per domain, so pull GET /v3/{domain}/bounces, GET /v3/{domain}/complaints and GET /v3/{domain}/unsubscribes for every domain you found. The Bird import takes one address per request and is idempotent, so a partial re-run is safe. https://bird.com/docs/guides/email/suppressions.md has the reason taxonomy.
6. Port the send call and the webhook handler using the mapping tables on the provider page. Two things need attention rather than translation: Mailgun reports one failed event with a severity field where Bird has separate deferred and bounced events, and Bird signs deliveries per Standard Webhooks rather than Mailgun's scheme, so treat verification as a rewrite. See https://bird.com/docs/guides/webhooks.md and https://bird.com/docs/guides/email/events.md.
7. Run my whole integration against Bird's mail sandbox before any production traffic, following https://bird.com/docs/guides/email/testing-sandbox.md. Sandbox sends run the real pipeline without reaching an inbox or touching my sending reputation.
8. Stop and ask me wherever a step needs a decision. Do not point production traffic at Bird until I have seen the sandbox results and replied with the words cut over to Bird. Retiring the Mailgun path is a separate step that comes later: ask me again and wait for me to reply with the words retire the Mailgun path. A reply that agrees without naming what it is authorising is not authorisation. Finish by telling me what is left that only a person can do.Zmapuj wywołanie wysyłki
Prefiksy parametrów Mailgun kodowanych jako formularz (opcje o:, zmienne v:, nagłówki h:) stają się pełnoprawnymi polami JSON w POST /v1/email/messages:
| Co robi | Mailgun | Bird |
|---|---|---|
| Nadawca | from | from |
| Odbiorcy | to / cc / bcc | to / cc / bcc (tablice) |
| Temat | subject | subject |
| Treść | html / text | html / text (co najmniej jedno) |
| Reply-to | h:Reply-To | reply_to (tablica) |
| Własne nagłówki | h:X-* | headers (obiekt string → string) |
| Etykiety do filtrowania | o:tag | tags: pary {name, value} |
| Kontekst zwrotny | v:* / X-Mailgun-Variables | metadata: dowolny JSON |
| Zapisany szablon | template + t:variables | template + template.parameters |
| Planowanie | o:deliverytime | scheduled_at |
| Śledzenie otwarć/kliknięć | o:tracking-opens / o:tracking-clicks | track_opens / track_clicks (domyślnie true) |
| Kategoria | (brak) | category: marketing (domyślnie) lub transactional |
Limity pól i wartości domyślne (liczba odbiorców, limity tagów i metadanych) znajdziesz w Wysyłanie e-maili.
Uwagi dotyczące portowania:
- Żądanie zmienia się na JSON. Mailgun przyjmuje dane multipart form. My przyjmujemy ciało JSON z Content-Type: application/json. To zazwyczaj największa mechaniczna zmiana przy portowaniu.
- Zmienne v: były zwracane w zdarzeniach. Nasze metadata działa tak samo. Zwracamy Twoje metadata (i tags) w każdym zdarzeniu webhooka obok email_id/recipient_id, więc Twoje handlery otrzymują je bez dodatkowego zapytania.
- Zmienne odbiorców nie przenoszą się jeden do jednego. recipient-variables w Mailgun personalizuje wielu odbiorców w jednym wywołaniu. U nas to zadanie należy do endpointu wsadowego, jeden wpis na odbiorcę, każdy z własną treścią lub własnymi wartościami parameters do podstawienia {{ token }}.
- Zapisane szablony przenoszą się bezpośrednio. Parametr template Mailgun mapuje się na nasze pole template z wartościami w template.parameters. Zobacz wysyłanie z szablonem.
- Załączniki przenoszą się bezpośrednio. Pliki multipart Mailgun attachment / inline stają się naszą tablicą attachments z content w base64 (ustaw content_id dla obrazów inline). Zobacz załączniki.
Eksportuj listy blokad
Mailgun prowadzi trzy listy per domena. Wyeksportuj każdą i przepuść przez pętlę importu:
- GET /v3/{domain}/bounces
- GET /v3/{domain}/complaints
- GET /v3/{domain}/unsubscribes
Powtórz dla każdej domeny wysyłkowej. Listy Mailgun mają zakres domeny, a nasze listy blokad mają zakres obszaru roboczego, więc importujesz sumę list ze wszystkich domen.
Przetłumacz zdarzenia webhooków
Mailgun sygnalizuje tymczasowe i trwałe błędy jednym zdarzeniem failed z polem severity. My je rozdzielamy:
| Rezultat | Mailgun | Bird |
|---|---|---|
| Zaakceptowano/przetworzono | accepted | email.accepted → email.processed |
| Dostarczono | delivered | email.delivered |
| Tymczasowy błąd | failed (temporary) | email.deferred |
| Trwałe odbicie | failed (permanent) | email.bounced / email.out_of_band_bounce |
| Skarga na spam | complained | email.complained |
| Zablokowano/wstrzymano | (brak) | email.rejected |
| Otwarcie | opened | email.opened |
| Kliknięcie | clicked | email.clicked |
| Wypisanie | unsubscribed | email.list_unsubscribed |
email.rejected nie ma odpowiednika w Mailgun: raportujemy wstrzymanych odbiorców jawnie (status rejected, rejection_reason: recipient_suppressed) zamiast pomijać ich po cichu. Dodaj dla tego zdarzenia handler zamiast traktować je jako odbicie.
Weryfikacja też się zmienia: Mailgun podpisuje za pomocą HMAC nad timestamp + token wewnątrz obiektu signature payloadu, a my podpisujemy zgodnie ze specyfikacją Standard Webhooks, używając nagłówków zamiast pól payloadu. Zamień swój kod weryfikacji na przepis z Webhooks & events.
Przełączenie
Przejdź przez domeny i DNS oraz test dymny w sandboxie w głównym przewodniku. Oba kroki są niezależne od dostawcy.
Następne kroki
- Domeny wysyłkowe: rejestracja, cykl życia weryfikacji i rekordy DNS, które przekierowujesz
- Webhooks & events: konfiguracja endpointu i weryfikacja Standard Webhooks
- Sandbox testowy: przetestuj nową integrację przed przełączeniem
- Listy blokad: sprawdź zaimportowaną listę i sposób, w jaki ją dalej utrzymujemy
Powiązane zasoby
Kontynuuj z dokumentacją, przewodnikami i przykładami dotyczącymi tego tematu. Zasoby są w języku angielskim.
Obejrzyj przewodnikGetting started with emailPoznaj możliwościEmailPodążaj ścieżką naukiBuild your first integrationPrzewodnik wdrożeniowySend your first email
Wypróbuj ćwiczenie i uzyskaj brief wdrożeniowy