feat: mailer internal, templates, bruno cleanup, create user, send welcome mail, mailtrap
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
_ "github.com/lib/pq"
|
||||
"greenlight.debuggingjon.dev/internal/data"
|
||||
"greenlight.debuggingjon.dev/internal/jsonlog"
|
||||
"greenlight.debuggingjon.dev/internal/mailer"
|
||||
)
|
||||
|
||||
// Declare a string containing the application version number. Later in the book we'll
|
||||
@@ -39,6 +40,13 @@ type config struct {
|
||||
burst int
|
||||
enabled bool
|
||||
}
|
||||
smtp struct {
|
||||
host string
|
||||
port int
|
||||
username string
|
||||
password string
|
||||
sender string
|
||||
}
|
||||
}
|
||||
|
||||
// Define an application struct to hold the dependencies for our HTTP handlers, helpers,
|
||||
@@ -48,6 +56,7 @@ type application struct {
|
||||
config config
|
||||
logger *jsonlog.Logger
|
||||
models data.Models
|
||||
mailer mailer.Mailer
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -80,6 +89,16 @@ func main() {
|
||||
flag.IntVar(&cfg.limiter.burst, "limiter-burst", 4, "Rate limiter maximum burst")
|
||||
flag.BoolVar(&cfg.limiter.enabled, "limiter-enabled", true, "Enable rate limiter")
|
||||
|
||||
// Read the SMTP server configuration settings into the config struct, using the
|
||||
// Mailtrap settings as the default values. IMPORTANT: If you're following along,
|
||||
// make sure to replace the default values for smtp-username and smtp-password
|
||||
// with your own Mailtrap credentials.
|
||||
flag.StringVar(&cfg.smtp.host, "smtp-host", "sandbox.smtp.mailtrap.io", "SMTP host")
|
||||
flag.IntVar(&cfg.smtp.port, "smtp-port", 25, "SMTP port")
|
||||
flag.StringVar(&cfg.smtp.username, "smtp-username", "3d946287da35ea", "SMTP username")
|
||||
flag.StringVar(&cfg.smtp.password, "smtp-password", "d06a774b484ca3", "SMTP password")
|
||||
flag.StringVar(&cfg.smtp.sender, "smtp-sender", "Greenlight <no-reply@greenlight.debuggingjon.dev>", "SMTP sender")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
// Call the openDB() helper function (see below) to create the connection pool,
|
||||
@@ -105,6 +124,7 @@ func main() {
|
||||
config: cfg,
|
||||
logger: logger,
|
||||
models: data.NewModels(db),
|
||||
mailer: mailer.New(cfg.smtp.host, cfg.smtp.port, cfg.smtp.username, cfg.smtp.password, cfg.smtp.sender),
|
||||
}
|
||||
|
||||
err = app.serve()
|
||||
|
||||
Reference in New Issue
Block a user