Clone the repo
go mod download
- Copy
.env.examplefile and paste it as.envin the same path - In
.envfile Add your email and password and leave other values as it is - Add your email address in
EMAIL_TOin which you want to receive your test email - For using OAUTH2 to send email and filling up environment variables
CLIENT_ID,CLIENT_SECRET,ACCESS_TOKENandREFRESH_TOKENfollow my medium article Sending Emails with GO (Golang) Using SMTP, Gmail, and OAuth2
- For sending test email using SMTP, execute following command
go run main.go SMTP
- For sending test email using Gmail API and OAUTH2, execute following command
go run main.go OAUTH
NOTE: Environment variables must be filled properly to be able to execute above commands