Clone the repo:
git clone https://github.com/vsevdrob/go-smtp
- After the
git clone
change directory and createsecret.env
:
cd go-smtp
touch secret.env
- In
secret.env
file, insert the outlook email address from which you are going to send emails. Also provide the password of that email (account) address. Then provide an email address of the recipient.
EMAIL_USERNAME="<account_name>@<domain_name>"
EMAIL_PASSWORD="UnCrACKa6LE-Pa$$W00RD"
EMAIL_RECIPIENT="<account_name>@<domain_name>"
(optional) In ./email/types.go
append additional keys:
...
type Env struct {
EmailUsername string `mapstructure:"EMAIL_USERNAME"`
EmailPassword string `mapstructure:"EMAIL_PASSWORD"`
EmailRecipient string `mapstructure:"EMAIL_RECIPIENT"`
// Append the rest here from that ./secret.env
}
Run commando after your secret.env
is set up:
go run main.go
- Go SMTP Standard Library documentation
- POP, IMAP, and SMTP settings for Outlook.com
- How to send emails in Go
- Load config from file & environment variables in Golang with Viper
MIT