A library that simplifies sending mail using "net/smtp"
You can commit PR to this repository
go get -u github.com/gobkc/mails
package main
import (
"github.com/gobkc/mails"
"log"
)
func main() {
mail := mails.Factory(&DefaultEmail{})
if err := mail.SetEnv("example@163.com", "examplepassword", "smtp.163.com:25"); err != nil {
log.Println(err.Error())
return
}
if err := mail.SendOTPToMail("example_send_to_mail@qq.com", "test otp", ""); err != nil {
log.Println(err.Error())
return
}
if err := mail.SendToMail("example_send_to_mail@qq.com", "test title", "test content"); err != nil {
log.Println(err.Error())
return
}
}
Note:The sender's SMTP function must be enabled
© Gobkc, 2022~time.Now
Released under the Apache License