{"id":27228346,"url":"https://github.com/devzolo/go-mail","last_synced_at":"2025-04-10T12:37:24.230Z","repository":{"id":232821029,"uuid":"708111618","full_name":"devzolo/go-mail","owner":"devzolo","description":null,"archived":false,"fork":false,"pushed_at":"2023-10-22T20:17:30.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T03:29:51.518Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/devzolo.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}},"created_at":"2023-10-21T15:03:24.000Z","updated_at":"2024-04-11T13:47:21.000Z","dependencies_parsed_at":"2024-04-11T17:16:15.638Z","dependency_job_id":"d3e7056b-82c3-4865-ae19-58e88d54c57d","html_url":"https://github.com/devzolo/go-mail","commit_stats":null,"previous_names":["devzolo/go-mail"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devzolo%2Fgo-mail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devzolo%2Fgo-mail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devzolo%2Fgo-mail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devzolo%2Fgo-mail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devzolo","download_url":"https://codeload.github.com/devzolo/go-mail/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248217150,"owners_count":21066633,"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":[],"created_at":"2025-04-10T12:37:20.834Z","updated_at":"2025-04-10T12:37:24.221Z","avatar_url":"https://github.com/devzolo.png","language":"Go","readme":"# 📧 Email Library\n\nA robust and flexible email sending library written in Go.\n\n## 🌟 Features\n\n- ✉️ Send plain-text or HTML emails.\n- 📎 Attach files to your emails.\n- 🔐 Supports SSL and TLS configurations.\n- 🛠 Easily extendable with functional options.\n\n## 📥 Installation\n\nInstall the library using:\n\n```bash\ngo get github.com/devzolo/go-mail\n```\n\n## 🚀 Usage\n\n### 1. **Initialization**\n\nSetup your SMTP server configuration:\n\n```go\nconfig := mail.EmailConfig{\n    Host:     \"smtp.example.com\",\n    Port:     587,\n    Username: \"your_username\",\n    Password: \"your_password\",\n    From:     \"sender@example.com\",\n    SSLMode:  false,\n}\n\nsender := mail.NewEmailSender(\n    mail.WithHost(config.Host),\n    mail.WithPort(config.Port),\n    mail.WithUsername(config.Username),\n    mail.WithPassword(config.Password),\n    mail.WithFrom(config.From),\n    // Add TLS config or enable SSLMode using additional setters if needed.\n)\n```\n\n### 2. **Sending an Email**\n\nCraft and send your message:\n\n```go\nemail := mail.Email{\n    To:      []string{\"recipient1@example.com\", \"recipient2@example.com\"},\n    Subject: \"Hello, World!\",\n    Body:    \"This is a plain-text email.\",\n}\n\n// For HTML emails:\n// email.SetHTMLBody(\"\u003ch1\u003eThis is an HTML email.\u003c/h1\u003e\")\n\nerr := sender.Send(email)\nif err != nil {\n    log.Fatal(\"❌ Failed to send email:\", err)\n}\n```\n\n### 3. **Attaching Files**\n\nTo add attachments:\n\n```go\nemail := mail.Email{\n    To:          []string{\"recipient@example.com\"},\n    Subject:     \"Here's your attachment\",\n    Body:        \"Please find the attached file.\",\n    Attachments: []string{\"path/to/your/file.txt\"},\n}\n\nerr := sender.Send(email)\nif err != nil {\n    log.Fatal(\"❌ Failed to send email:\", err)\n}\n```\n\n## 📦 Dependencies\n\n- [gomail.v2](https://pkg.go.dev/gopkg.in/gomail.v2)\n\n## ⚠️ Error Handling\n\nAlways handle errors. The library checks for emails without recipients:\n\n```go\nerr := sender.Send(email)\nif err != nil {\n    if err.Error() == mail.ErrNoRecipients {\n        log.Println(\"⚠️ No recipients specified for the email.\")\n    } else {\n        log.Fatal(\"❌ Failed to send email:\", err)\n    }\n}\n```\n\n## 👥 Contribute\n\nJump in! 🏊‍♂️ [Open an issue](https://github.com/devzolo/go-mail/issues) or submit PRs.\n\n## 📜 License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevzolo%2Fgo-mail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevzolo%2Fgo-mail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevzolo%2Fgo-mail/lists"}