Xiang Fu
Seunghyun
02/07/2022, 8:01 PMfunc SendEmailViaGmail(c *Config, subject string, htmlContent string) string {
d := gomail.NewDialer("<http://smtp.gmail.com|smtp.gmail.com>", 587, c.GmailAccount, c.GmailAppPassword)
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
// Send emails using d.
m := gomail.NewMessage()
m.SetAddressHeader("From", c.From, "Pinot Slack Email Digest")
m.SetHeader("To", <http://c.To|c.To>)
m.SetHeader("Subject", subject)
m.SetBody("text/html", htmlContent)
err := d.DialAndSend(m)
if err != nil {
fmt.Println("Failed to send the mail via Sendgrid: " + err.Error())
return "Failed to send mail via Sendgrid: " + err.Error()
} else {
msg := fmt.Sprintf("Daily digest successfully sent with the title: `%s`\n", DigestTitle())
fmt.Println(msg)
return msg
}
}
Seunghyun
02/07/2022, 8:03 PMFailed to send the mail via Sendgrid
. Sendgrid needs to be changed to Google SMTP
. I copied the block from another function. Anyway, it looks that the usersname & password doesn’t matchSeunghyun
02/07/2022, 8:03 PMSeunghyun
02/07/2022, 8:03 PMapachepinot
accountSeunghyun
02/07/2022, 8:04 PMSeunghyun
02/07/2022, 8:04 PMSeunghyun
02/07/2022, 8:04 PMXiang Fu
Xiang Fu