a smtp sender written by golang
##install
go get github.com/voids/gsender
import (
"github.com/voids/gsender"
)
##demo
sender := new(gsender.Sender)
sender.Address = "[email protected]"
sender.Name = "voids"
sender.Password = "********"
sender.Host = "smtp.example.com"
sender.Port = 25
// sender.TLS = true
msg := new(gsender.Message)
// msg.Html = true
msg.SetSubject("A test email")
msg.SetBody("this is a test email which sent by golang.")
if err := msg.AddAttachment(`/home/voids/pic.jpg`); err != nil {
panic(err)
}
receiver := new(gsender.Receiver)
receiver.AddTo("John", "[email protected]")
receiver.AddTo("Lily", "[email protected]")
receiver.AddCc("Dog", "[email protected]")
receiver.AddBcc("hacker", "[email protected]")
if err := sender.Send(msg, receiver); err != nil {
panic(err)
}