An easy way to send emails with attachments in Go
Install / Use
/learn @scorredoira/EmailREADME
PROJECT DISCONTINUED
This repository only exists for archival purposes.
email

An easy way to send emails with attachments in Go
Install
go get github.com/scorredoira/email
Usage
package email_test
import (
"log"
"net/mail"
"net/smtp"
"github.com/scorredoira/email"
)
func Example() {
// compose the message
m := email.NewMessage("Hi", "this is the body")
m.From = mail.Address{Name: "From", Address: "from@example.com"}
m.To = []string{"to@example.com"}
// add attachments
if err := m.Attach("email.go"); err != nil {
log.Fatal(err)
}
// add headers
m.AddHeader("X-CUSTOMER-id", "xxxxx")
// send it
auth := smtp.PlainAuth("", "from@example.com", "pwd", "smtp.zoho.com")
if err := email.Send("smtp.zoho.com:587", auth, m); err != nil {
log.Fatal(err)
}
}
Html
// use the html constructor
m := email.NewHTMLMessage("Hi", "this is the body")
Inline
// use Inline to display the attachment inline.
if err := m.Inline("main.go"); err != nil {
log.Fatal(err)
}
Related Skills
node-connect
339.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.8kCommit, push, and open a PR
