go-gomail / gomail

The best way to send emails in Go.
MIT License
4.29k stars 569 forks source link

Not receiving email when sending email as No SMTP. #181

Open StevenOng97 opened 1 year ago

StevenOng97 commented 1 year ago

Hi @alexcesaro , I followed the guide from our documentation but don't receive any email. Even no error throw from the log.

m := gomail.NewMessage() m.SetHeader("From", "from@example.com") m.SetHeader("To", "to@example.com") m.SetHeader("Subject", "Hello!") m.SetBody("text/plain", "Hello!")

s := gomail.SendFunc(func(from string, to []string, msg io.WriterTo) error { // Implements you email-sending function, for example by calling // an API, or running postfix, etc. fmt.Println("From:", from) fmt.Println("To:", to) return nil })

if err := gomail.Send(s, m); err != nil { panic(err) }

wneessen commented 1 year ago

Your gomail.SendFunc basically only prints out the "From" and "To" fields of the mail but does not perform any sending operation. You followed the "No SMTP" example which basically means it does not send the mail via SMTP and leaves it up to you to write your own delivery function. Why did you chose this example when you are expecting to send mails?