{"id":19199377,"url":"https://github.com/supme/smtpsender","last_synced_at":"2025-05-09T01:22:58.028Z","repository":{"id":57491729,"uuid":"117539537","full_name":"Supme/smtpSender","owner":"Supme","description":"build and send email","archived":false,"fork":false,"pushed_at":"2023-03-07T00:23:32.000Z","size":551,"stargazers_count":17,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T20:12:04.181Z","etag":null,"topics":["golang","smtp"],"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/Supme.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}},"created_at":"2018-01-15T11:57:03.000Z","updated_at":"2024-10-05T07:19:23.000Z","dependencies_parsed_at":"2024-06-19T01:28:29.778Z","dependency_job_id":null,"html_url":"https://github.com/Supme/smtpSender","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Supme%2FsmtpSender","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Supme%2FsmtpSender/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Supme%2FsmtpSender/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Supme%2FsmtpSender/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Supme","download_url":"https://codeload.github.com/Supme/smtpSender/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253172159,"owners_count":21865472,"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":["golang","smtp"],"created_at":"2024-11-09T12:26:53.692Z","updated_at":"2025-05-09T01:22:57.967Z","avatar_url":"https://github.com/Supme.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# smtpSender\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/Supme/smtpSender)](https://goreportcard.com/report/github.com/Supme/smtpSender)\n\nSee cmd/sendemail.go file for example\n```\ngo build -o sendemail sendemail.go\nsendemail -h\nsendemail -f from@domain.tld -t to@domain.tld -s \"Hello subject!\" -m \"Hello, world!\"\nsendemail -f from@domain.tld -t to@domain.tld -s \"Hello subject!\" -html ./message.html -amp ./amp.html -txt ./message.txt\n```\n\nSend email\n```\nbldr := \u0026smtpSender.Builder{\n\tFrom: \"Sender \u003csender@domain.tld\u003e\",\n\tTo: \"Me \u003cme+test@mail.tld\u003e\",\n\tSubject: \"Test subject\",\n}\nbldr.SetDKIM(\"domain.tld\", \"test\", myPrivateKey)\nbldr.AddHeader(\"Content-Language: ru\", \"Message-ID: \u003cId-123\u003e\", \"Precedence: bulk\")\nbldr.AddTextPart(\"textPlain\")\nbldr.AddHTMLPart(\"\u003ch1\u003etextHTML\u003c/h1\u003e\u003cimg src=\\\"cid:image.gif\\\"/\u003e\", \"./image.gif\")\nbldr.AddAttachment(\"./file.zip\", \"./music.mp3\")\nemail := bldr.Email(\"Id-123\", func(result smtpSender.Result){\n\tfmt.Printf(\"Result for email id '%s' duration: %f sec result: %v\\n\", result.ID, result.Duration.Seconds(), result.Err)\n})\n\t\nconn := new(smtpSender.Connect)\nconn.SetHostName(\"sender.domain.tld\")\nconn.SetMapIP(\"192.168.0.10\", \"31.32.33.34\")\n\t\nemail.Send(conn, nil)\n\nor\n\nserver = \u0026smtpSender.SMTPserver{\n\tHost:     \"smtp.server.tld\",\n\tPort:     587,\n\tUsername: \"sender@domain.tld\",\n\tPassword: \"password\",\n}\nemail.Send(conn, server)\n```\n\n\nBest way send email from pool\n```\npipe := smtpSender.NewPipe(\n\tsmtpSender.Config{\n\t\tIface:  \"31.32.33.34\",\n\t\tStream:   5,\n\t},\n\tsmtpSender.Config{\n\t\tIface:  \"socks5://222.222.222.222:7080\",\n\t\tStream: 2,\n\t})\npipe.Start()\n\nfor i := 1; i \u003c= 50; i++ {\n    bldr := new(smtpSender.Builder)\n    bldr.SetFrom(\"Sender\", \"sender@domain.tld\")\n    bldr.SetTo(\"Me\", \"me+test@mail.tld\")\n    bldr.SetSubject(\"Test subject \" + id)\n    bldr.AddHTMLPart(\"\u003ch1\u003etextHTML\u003c/h1\u003e\u003cimg src=\\\"cid:image.gif\\\"/\u003e\", \"./image.gif\")\n    email := bldr.Email(id, func(result smtpSender.Result) {\n       \tfmt.Printf(\"Result for email id '%s' duration: %f sec result: %v\\n\", result.ID, result.Duration.Seconds(), result.Err)\n       \twg.Done()\n    })\n\terr := pipe.Send(email)\n\tif err != nil {\n\t\tfmt.Printf(\"Send email id '%d' error %+v\\n\", i, err)\n\t\tbreak\n\t}\n\tif i == 35 {\n\t\tpipe.Stop()\n\t}\n}\n```\n\n\nUse template for email\n```\nimport (\n\t...\n\ttmplHTML \"html/template\"\n\ttmplText \"text/template\"\n)\n    ...\n\tsubj := tmplText.New(\"Subject\")\n\tsubj.Parse(\"{{.Name}} this template subject text.\")\n\thtml := tmplHTML.New(\"HTML\")\n\thtml.Parse(`\u003ch1\u003eThis 'HTML' template.\u003c/h1\u003e\u003cimg src=\"cid:image.gif\"\u003e\u003ch2\u003eHello {{.Name}}!\u003c/h2\u003e`)\n\ttext := tmplText.New(\"Text\")\n\ttext.Parse(\"This 'Text' template. Hello {{.Name}}!\")\n\tdata := map[string]string{\"Name\": \"Вася\"}\n\tbldr.AddSubjectFunc(func(w io.Writer) error {\n\t\treturn subj.Execute(w, \u0026data)\n\t})\n\tbldr.AddTextFunc(func(w io.Writer) error {\n\t\treturn text.Execute(w, \u0026data)\n\t})\n\tbldr.AddHTMLFunc(func(w io.Writer) error {\n\t\treturn html.Execute(w, \u0026data)\n\t}, \"./image.gif\")\n    ...\n```\n\n\nOne more method send email from pool (Depricated)\n```\nemailPipe := smtpSender.NewEmailPipe(\n\tsmtpSender.Config{\n\t\tIface:  \"31.32.33.34\",\n\t\tStream:   5,\n\t},\n\tsmtpSender.Config{\n\t\tIface:  \"socks5://222.222.222.222:7080\",\n\t\tStream: 2,\n\t})\n\nstart := time.Now()\nwg := \u0026sync.WaitGroup{}\nfor i := 1; i \u003c= 15; i++ {\n\tid := \"Id-\" + strconv.Itoa(i)\n\tbldr := new(smtpSender.Builder)\n\tbldr.SetFrom(\"Sender\", \"sender@domain.tld\")\n\tbldr.SetTo(\"Me\", \"me+test@mail.tld\")\n\tbldr.SetSubject(\"Test subject \" + id)\n\tbldr.SetDKIM(\"domain.tld\", \"test\", myPrivateKey)\n\tbldr.AddHeader(\"Content-Language: ru\", \"Message-ID: \u003cId-123\u003e\", \"Precedence: bulk\")\n\tbldr.AddTextPart(\"textPlain\")\n\tbldr.AddHTMLPart(\"\u003ch1\u003etextHTML\u003c/h1\u003e\u003cimg src=\\\"cid:image.gif\\\"/\u003e\", \"./image.gif\")\n\tbldr.AddAttachment(\"./file.zip\", \"./music.mp3\")\n\twg.Add(1)\n\temail := bldr.Email(id, func(result smtpSender.Result) {\n\t\tfmt.Printf(\"Result for email id '%s' duration: %f sec result: %v\\n\", result.ID, result.Duration.Seconds(), result.Err)\n\t\twg.Done()\n\t})\n\temailPipe \u003c- email\n}\nwg.Wait()\n\nfmt.Printf(\"Stream send duration: %s\\r\\n\", time.Now().Sub(start).String())\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsupme%2Fsmtpsender","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsupme%2Fsmtpsender","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsupme%2Fsmtpsender/lists"}