{"id":20735721,"url":"https://github.com/iamfaizankhalid/goemail","last_synced_at":"2026-05-25T22:35:26.703Z","repository":{"id":57577218,"uuid":"358193828","full_name":"IamFaizanKhalid/goemail","owner":"IamFaizanKhalid","description":"Send simple/html email easily with attachments in golang.","archived":false,"fork":false,"pushed_at":"2021-04-17T04:57:27.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-18T01:09:57.613Z","etag":null,"topics":["attachment","email","golang","smtp","template"],"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/IamFaizanKhalid.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":"2021-04-15T09:01:05.000Z","updated_at":"2021-09-21T18:45:27.000Z","dependencies_parsed_at":"2022-09-11T23:51:12.602Z","dependency_job_id":null,"html_url":"https://github.com/IamFaizanKhalid/goemail","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IamFaizanKhalid%2Fgoemail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IamFaizanKhalid%2Fgoemail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IamFaizanKhalid%2Fgoemail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IamFaizanKhalid%2Fgoemail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IamFaizanKhalid","download_url":"https://codeload.github.com/IamFaizanKhalid/goemail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243021772,"owners_count":20223068,"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":["attachment","email","golang","smtp","template"],"created_at":"2024-11-17T05:39:22.325Z","updated_at":"2025-12-24T22:17:38.024Z","avatar_url":"https://github.com/IamFaizanKhalid.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goemail [![Build Status](https://api.travis-ci.com/IamFaizanKhalid/goemail.svg?branch=master)](https://travis-ci.com/github/IamFaizanKhalid/goemail) [![Go Report Card](https://goreportcard.com/badge/github.com/IamFaizanKhalid/goemail)](https://goreportcard.com/report/github.com/IamFaizanKhalid/goemail) ![License](https://img.shields.io/badge/license-MIT-blue.svg)\n\u003cimg align=\"right\" src=\"https://mimepost.com/blog/content/images/size/w600/2021/02/Untitled_design-removebg-preview-1.png\" width=\"250\"\u003e\n\nA wrapper over `net/smtp` to make sending email easier in go.\n\n## Features \n- HTML email\n- HTML template email\n- Attach file (`[]byte`, `os.File` or by file path)\n\n## Usage\n\n### 1. Get Client:\nUse your smtp server credentials to get client object.\n```go\nclient := goemail.NewClient(\u0026goemail.Config{\n    Host:     \"smtp.gmail.com\",\n    Port:     587,\n    Email:    \"user@example.com\",\n    Password: \"password\",\n})\n```\n\n### 2. Get Mailer:\nGet a new mailer object from the client for each new email to send.\n```go\nmailer := client.NewMailer(\"Test Email\", \"This is an email for testing.\")\n})\n```\n\n### 3. Build Email and Send:\nAdd recipients of your email.\nAttach a file if you need to.\nAnd send the email.\n```go\nmailer.AddRecipients([]mail.Address{\n    {\n        Name:  \"Random Guy\",\n        Address: \"randomguy123@example.com\",\n    },\n})\nmailer.AddBlindCopyRecipients([]mail.Address{\n    {\n        Address: \"secret01@example.com\",\n    },\n})\nmailer.SetSender(mail.Address{\n    Name:  \"Faizan Khalid\",\n})\n\nmailer.SetReplyToEmail(\"no-reply@example.com\")\n\n_ = mailer.AttachFile(\"../Downloads/my_file.pdf\")\n\n_ = mailer.Send()\n```\n\n\n## Html Template Example\n\n```go\npackage main\n\nimport (\n    \"github.com/IamFaizanKhalid/goemail\"\n    \"log\"\n    \"net/mail\"\n)\n\nfunc main() {\n    client := goemail.NewClient(\u0026goemail.Config{\n        Host:     \"smtp.gmail.com\",\n        Port:     587,\n        Email:    \"user@example.com\",\n        Password: \"password\",\n    })\n    \n    templateValues := struct {\n        Name  string\n        Url   string\n        Title string\n    }{\n        Name:  \"John Doe\",\n        Url:   \"http://johndoe.com\",\n        Title: \"Welcome to my Homepage\",\n    }\n        \n    mailer, err := client.NewHtmlMailerFromTemplate(\"JohnDoe.com\", \"welcome.html\", templateValues)\n    if err != nil {\n        log.Println(err)\n        return\n    }\n\n    mailer.AddRecipients([]mail.Address{{Address: \"IamFaizanKhalid@gmail.com\"}})\n\n    err = mailer.Send()\n    if err != nil {\n        log.Println(err)\n        return\n    }\n}\n```\n\n## Known Issues\n\n- `AddInlineFile()` adds gibberish in the email.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamfaizankhalid%2Fgoemail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamfaizankhalid%2Fgoemail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamfaizankhalid%2Fgoemail/lists"}