Created
November 9, 2023 06:06
-
-
Save michael-halim/39b688159ab9fa741b961ec77cce0bef to your computer and use it in GitHub Desktop.
Sending Email with Gomail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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