Skip to content

Instantly share code, notes, and snippets.

@michael-halim
Created November 9, 2023 06:06
Show Gist options
  • Save michael-halim/39b688159ab9fa741b961ec77cce0bef to your computer and use it in GitHub Desktop.
Save michael-halim/39b688159ab9fa741b961ec77cce0bef to your computer and use it in GitHub Desktop.
Sending Email with Gomail
mailer := gomail.NewMessage()
dialer := gomail.NewDialer(
SmtpHost,
SmtpPort,
Username,
Password,
)
mailer.SetHeader("From", "Sender Name" + "<" + "Sender Email" + ">")
mailer.SetHeader("To", "Reveiver Email")
mailer.SetHeader("Subject", "Email Subject")
mailer.SetBody("Email Content Type", "Body")
err := dialer.DialAndSend(mailer)
if err != nil {
return err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment