{"id":15686360,"url":"https://github.com/mattes/go-mail","last_synced_at":"2025-05-07T18:41:15.014Z","repository":{"id":57605632,"uuid":"221165718","full_name":"mattes/go-mail","owner":"mattes","description":"Render and send emails with Go","archived":false,"fork":false,"pushed_at":"2019-11-13T07:54:58.000Z","size":870,"stargazers_count":11,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T12:58:09.585Z","etag":null,"topics":["css-inliner","emails","go","golang","mail","markdown","templates"],"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/mattes.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}},"created_at":"2019-11-12T08:19:26.000Z","updated_at":"2025-03-25T21:45:48.000Z","dependencies_parsed_at":"2022-08-27T22:41:02.301Z","dependency_job_id":null,"html_url":"https://github.com/mattes/go-mail","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattes%2Fgo-mail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattes%2Fgo-mail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattes%2Fgo-mail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattes%2Fgo-mail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattes","download_url":"https://codeload.github.com/mattes/go-mail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252936114,"owners_count":21828078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["css-inliner","emails","go","golang","mail","markdown","templates"],"created_at":"2024-10-03T17:38:43.389Z","updated_at":"2025-05-07T18:41:14.995Z","avatar_url":"https://github.com/mattes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-mail [![GoDoc](https://godoc.org/github.com/mattes/go-mail?status.svg)](https://godoc.org/github.com/mattes/go-mail)\n\n* Load template files from disk or embedded store.\n* Preview rendered template files with example data in browser with [go-mail-preview tool](./go-mail-preview).\n* Automatically [inlines CSS](https://github.com/aymerick/douceur).\n* Powered by Go's [html/template](https://golang.org/pkg/html/template/) and [text/template](https://golang.org/pkg/text/template/) engine.\n* Supports [markdown](https://github.com/yuin/goldmark) to HTML parsing inside template.\n* Use [provider](./provider) to send an email.\n\n## Usage\n\n```go\nimport (\n  \"github.com/mattes/go-mail\"\n  \"github.com/mattes/go-mail/provider/mailgun\"\n)\n\n// load templates\ntpl, err := mail.NewTemplates(mail.FilesFromLocalDir(\"./templates\"))\n\n// create mail envelope\nm := mail.New()\nm.Subject = \"Advice to self\"\nm.To(\"Mattes\", \"mattes@example.com\")\nm.Template(tpl, \"simple\", mail.Vars{\n  \"Body\": \"no ice cream after midnight\",\n})\n\n// send email with mailgun (or any other provider)\np, err := mailgun.New(\"mailgun-domain\", \"mailgun-key\")\nerr = p.Send(m)\n```\n\n## Templates\n\n### Structure\n\nEmails can have a HTML and/or text body. Templates are recognized by\ntheir file extension.\n\n```\nmy-template.html         -\u003e used for html body, processed with Go's html/template engine\nmy-template.txt          -\u003e used for text body, processed with Go's text/template engine\nmy-template.example.yaml -\u003e used for preview\n```\n\n### Embed templates into Go binary\n\nTo embed templates into your Go binary, you can use a tool like\n[go.rice](https://github.com/GeertJohan/go.rice).\n\nInstall go.rice first:\n\n```\ngo get github.com/GeertJohan/go.rice\ngo get github.com/GeertJohan/go.rice/rice\n```\n\nUpdate your go code:\n\n```go\n//go:generate rice embed-go\n\nvar MyTemplates = rice.MustFindBox(\"./path/to/templates\")\n```\n\nRun `go generate` to generate the embedded file. See [files.go](./files.go) and\n[files_test.go](./files_test.go) for an example.\n\n\n### Nice templates\n\nThere is a couple of tested email templates available, please have a look at:\n\n* https://github.com/wildbit/postmark-templates\n* https://github.com/mailgun/transactional-email-templates\n* https://github.com/leemunroe/responsive-html-email-template\n* https://github.com/leemunroe/amp-email-templates\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattes%2Fgo-mail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattes%2Fgo-mail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattes%2Fgo-mail/lists"}