...
1# Hexacode Mailer
2
3[![GoDoc](https://pkg.go.dev/badge/github.com/gin-gonic/gin?status.svg)](https://docs-go.hexacode.org/pkg/gitlab.hexacode.org/go-libs/mailer/)
4
5## Example
6```go
7package main
8
9import (
10 "gitlab.hexacode.org/go-libs/hctypes"
11 "gitlab.hexacode.org/go-libs/mailer"
12)
13
14func main() {
15 // Create a new template
16 // Please see https://github.com/noirbizarre/gonja for more details template
17 tmpl, err := mailer.NewTemplate("Hello {{ name }}!")
18 if err != nil {
19 panic(err)
20 }
21
22 // Create a new sender
23 sender := mailer.NewSender("Example Sender", "example-sender@gmail.com", "password", "smtp.gmail.com", 587, tmpl)
24
25 // Send an email
26 err = sender.SendEmail("example-recipient@gmail.com", "Example Subject", hctypes.Dict{"name": "John Doe"})
27 if err != nil {
28 panic(err)
29 }
30}
31```
View as plain text