{"id":51102637,"url":"https://github.com/gzuidhof/myrtle","last_synced_at":"2026-06-24T12:01:13.669Z","repository":{"id":342376528,"uuid":"1162730821","full_name":"gzuidhof/myrtle","owner":"gzuidhof","description":"Modern emails for Go","archived":false,"fork":false,"pushed_at":"2026-03-12T11:48:11.000Z","size":3489,"stargazers_count":26,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-28T13:35:28.628Z","etag":null,"topics":["email","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gzuidhof.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-20T16:16:01.000Z","updated_at":"2026-03-16T07:08:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/gzuidhof/myrtle","commit_stats":null,"previous_names":["gzuidhof/myrtle"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gzuidhof/myrtle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gzuidhof%2Fmyrtle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gzuidhof%2Fmyrtle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gzuidhof%2Fmyrtle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gzuidhof%2Fmyrtle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gzuidhof","download_url":"https://codeload.github.com/gzuidhof/myrtle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gzuidhof%2Fmyrtle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34731256,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","go","golang"],"created_at":"2026-06-24T12:01:12.884Z","updated_at":"2026-06-24T12:01:13.661Z","avatar_url":"https://github.com/gzuidhof.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"example/server/assets/logo-light.png\"\u003e\n    \u003cimg alt=\"Myrtle logo\" src=\"example/server/assets/logo.png\"\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\n# 🌸 myrtle\nMyrtle is a composable, strongly typed email content builder for Go.\n\n| Default | Terminal |\n| --- | --- |\n| ![Security example (default)](example/screenshot/default--security.png) | ![Security example (terminal)](example/screenshot/terminal--security.png) |\n\n## Features\n\n- Fluent builder pattern for email content.\n- Strongly typed library of blocks.\n- Modern built-in themes: `default`, `flat`, `terminal`, `editorial`.\n- Built-in advanced blocks such as tables, charts, grids.\n- High-impact blocks: timelines, standout stats rows, badges, attachments.\n- Dual rendering APIs:\n  - `HTML()` for final HTML output.\n  - `Text()` for plain-text fallback output.\n- Customizable and extensible: bring your own theme, styles or custom blocks.\n- Left-to-right and right-to-left direction support (e.g. for Arabic/Hebrew).\n- Renders OK in Outlook Classic and other notoriously difficult email clients.\n- Dependency-free aside from [`goldmark`](https://github.com/yuin/goldmark) for Markdown rendering.\n\n## Installation\n\n```bash\ngo get github.com/gzuidhof/myrtle\n```\n\n## Quick start (security email)\n\n```go\npackage main\n\nimport (\n  \"github.com/gzuidhof/myrtle\"\n  defaulttheme \"github.com/gzuidhof/myrtle/theme/default\"\n)\n\nfunc main() {\n  email := myrtle.NewBuilder(defaulttheme.New()).\n    WithPreheader(\"Use this one-time code to sign in\").\n    AddHeading(\"Your verification code\").\n    AddText(\"Use the code below to complete your sign-in. This code expires in 10 minutes.\").\n    AddVerificationCode(\"Verification code\", \"493817\").\n    AddKeyValue(\"Request details\", []myrtle.KeyValuePair{\n      {Key: \"IP\", Value: \"203.0.113.5\"},\n      {Key: \"Location\", Value: \"Amsterdam, NL\"},\n    }).\n    AddText(\"If you did not request this code, secure your account immediately.\").\n    AddButton(\"Review account\", \"https://example.com/account/security\").\n    Build()\n\n  html, err := email.HTML()\n  if err != nil {\n    panic(err)\n  }\n\n  md, err := email.Text()\n  if err != nil {\n    panic(err)\n  }\n\n  // Use your favorite e-mail sending library to send the email with the generated HTML and text content.\n  // ...\n\n  _ = html\n  _ = md\n}\n```\n\nMake use of auto-complete/Intellisense in your IDE to explore the rich library of blocks and customization options.\n\n## Expandable snippets\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eCustom block (basic)\u003c/strong\u003e\u003c/summary\u003e\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n\n  \"github.com/gzuidhof/myrtle\"\n  \"github.com/gzuidhof/myrtle/theme\"\n  defaulttheme \"github.com/gzuidhof/myrtle/theme/default\"\n)\n\ntype DeploymentStatus struct {\n  Service string\n  Version string\n  Status  string\n}\n\nfunc main() {\n  block := myrtle.NewCustomBlock(\n    theme.BlockKind(\"deployment_status\"),\n    DeploymentStatus{Service: \"billing-api\", Version: \"v1.42.0\", Status: \"healthy\"},\n    func(v DeploymentStatus, values theme.Values) (string, error) {\n      _ = values\n      return fmt.Sprintf(\"\u003cp\u003e\u003cstrong\u003e%s\u003c/strong\u003e on \u003ccode\u003e%s\u003c/code\u003e: %s\u003c/p\u003e\", v.Service, v.Version, v.Status), nil\n    },\n    func(v DeploymentStatus, context myrtle.RenderContext) (string, error) {\n      _ = context\n      return fmt.Sprintf(\"%s on %s: %s\", v.Service, v.Version, v.Status), nil\n    },\n  )\n\n  email := myrtle.NewBuilder(defaulttheme.New()).\n    AddHeading(\"Deployment update\").\n    Add(block).\n    Build()\n\n  _, _ = email.HTML()\n  _, _ = email.Text()\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eStyle tweaks (basic)\u003c/strong\u003e\u003c/summary\u003e\n\n```go\npackage main\n\nimport (\n  \"github.com/gzuidhof/myrtle\"\n  \"github.com/gzuidhof/myrtle/theme\"\n  defaulttheme \"github.com/gzuidhof/myrtle/theme/default\"\n)\n\nfunc main() {\n  styles := theme.DefaultDarkModeStyles()\n  styles.ColorPrimary = \"#22d3ee\"\n  styles.MaxWidthMain = \"640px\"\n  styles.MainContentBodyTopSpacing = \"0\"\n\n  email := myrtle.NewBuilder(\n    defaulttheme.New(),\n    myrtle.WithStyles(styles),\n  ).\n    WithPreheader(\"Theme overrides example\").\n    AddHeading(\"Style tweaks\").\n    AddText(\"This message uses a dark preset with a few token overrides.\").\n    AddButton(\"Open dashboard\", \"https://example.com/dashboard\").\n    Build()\n\n  _, _ = email.HTML()\n  _, _ = email.Text()\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eConcurrent rendering with shared header/footer/theme/styles\u003c/strong\u003e\u003c/summary\u003e\n\n```go\npackage main\n\nimport (\n  \"sync\"\n\n  \"github.com/gzuidhof/myrtle\"\n  \"github.com/gzuidhof/myrtle/theme\"\n  defaulttheme \"github.com/gzuidhof/myrtle/theme/default\"\n)\n\ntype RenderedEmail struct {\n  To   string\n  HTML string\n  Text string\n  Err  error\n}\n\nfunc main() {\n  // Shared theme/styles/header/footer used to build one baseline builder.\n  sharedStyles := theme.Styles{\n    ColorPrimary: \"#2563eb\",\n    MaxWidthMain: \"640px\",\n  }\n\n  sharedHeader := myrtle.NewGroup().\n    AddImage(\"https://example.com/logo.png\", \"Myrtle\", myrtle.ImageWidth(120), myrtle.ImageAlign(myrtle.ImageAlignmentCenter)).\n    AddText(\"Security updates\", myrtle.TextAlign(myrtle.TextAlignCenter), myrtle.TextWeight(myrtle.TextWeightSemibold))\n\n  sharedFooter := myrtle.NewGroup().\n    AddLegal(\n      \"Myrtle Inc.\",\n      \"Dam Square 1, 1012 JS Amsterdam, Netherlands\",\n      \"https://example.com/preferences\",\n      \"https://example.com/unsubscribe\",\n    )\n\n  baseBuilder := myrtle.NewBuilder(defaulttheme.New(), myrtle.WithStyles(sharedStyles)).\n    WithHeader(sharedHeader).\n    WithFooter(sharedFooter).\n    WithPreheader(\"Important account security update\")\n\n  recipients := []string{\"ana@example.com\", \"bo@example.com\", \"cy@example.com\"}\n  results := make([]RenderedEmail, len(recipients))\n\n  var wg sync.WaitGroup\n  for i, to := range recipients {\n    wg.Add(1)\n    go func(i int, to string) {\n      defer wg.Done()\n\n      // Clone the baseline builder and apply recipient-specific content.\n      email := baseBuilder.Clone().\n        AddHeading(\"Account alert\").\n        AddText(\"We detected a sign-in from a new location.\").\n        AddKeyValue(\"Recipient\", []myrtle.KeyValuePair{{Key: \"Email\", Value: to}}).\n        AddButton(\"Review activity\", \"https://example.com/security\").\n        Build()\n\n      html, err := email.HTML()\n      if err != nil {\n        results[i] = RenderedEmail{To: to, Err: err}\n        return\n      }\n\n      text, err := email.Text()\n      results[i] = RenderedEmail{To: to, HTML: html, Text: text, Err: err}\n    }(i, to)\n  }\n  wg.Wait()\n\n  _ = results\n}\n```\n\n\u003c/details\u003e\n\n## Examples\n\n- [example/weekly_operations_brief.go](example/high_impact.go)\n- [example/account_deletion_confirmation.go](example/account_deletion_confirmation.go)\n- [example/security.go](example/security.go)\n- [example/monster.go](example/monster.go)\n\n### Rendered examples\n\n#### Weekly operations brief\n\n| Default | Flat |\n| --- | --- |\n| ![Weekly operations brief (default)](example/screenshot/default--weekly-operations-brief.png) | ![Weekly operations brief (flat)](example/screenshot/flat--weekly-operations-brief.png) |\n| Terminal | Editorial |\n| ![Weekly operations brief (terminal)](example/screenshot/terminal--weekly-operations-brief.png) | ![Weekly operations brief (editorial)](example/screenshot/editorial--weekly-operations-brief.png) |\n\n#### Account deletion confirmation\n\n| Default | Flat |\n| --- | --- |\n| ![Account deletion confirmation (default)](example/screenshot/default--account-deletion-confirmation.png) | ![Account deletion confirmation (flat)](example/screenshot/flat--account-deletion-confirmation.png) |\n| Terminal | Editorial |\n| ![Account deletion confirmation (terminal)](example/screenshot/terminal--account-deletion-confirmation.png) | ![Account deletion confirmation (editorial)](example/screenshot/editorial--account-deletion-confirmation.png) |\n\n#### Security confirmation\n\n| Default | Flat |\n| --- | --- |\n| ![Security confirmation (default)](example/screenshot/default--security.png) | ![Security confirmation (flat)](example/screenshot/flat--security.png) |\n| Terminal | Editorial |\n| ![Security confirmation (terminal)](example/screenshot/terminal--security.png) | ![Security confirmation (editorial)](example/screenshot/editorial--security.png) |\n\n#### Monster\n\nThe monster example is a fun showcase of many blocks and styles together. It intentionally has a lot of content to demonstrate how the builder and themes handle it.\n\n- [example/screenshot/default--monster.png](example/screenshot/default--monster.png)\n\n## Example server\n\nThe [example/server](example/server) package serves a directory of all example emails and block previews.\n\nClone this repository and run the server to preview example emails in the browser at `http://localhost:8380/`.\n\n```bash\ngo run ./example/server/cmd\n```\n\n![Example server preview](example/screenshot/example-server.png)\n\n## Development\nThe code for this repository is repetitive and verbose, I recommend you use AI-assisted code generation to speed up development. Writing inlined CSS manually is particularly painful.\n\nThis library is not stable yet, your layouts will likely shift a bit with future releases.\n\n## License\nMyrtle is licensed under the MIT License. See [LICENSE](LICENSE) for more information.\n\n\u003e Myrtle she wrote.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgzuidhof%2Fmyrtle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgzuidhof%2Fmyrtle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgzuidhof%2Fmyrtle/lists"}