You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
715 B
34 lines
715 B
package features_email
|
|
|
|
import (
|
|
email "MY/webapp/common/email"
|
|
"context"
|
|
"github.com/gofiber/fiber/v2"
|
|
. "MY/webapp/common"
|
|
)
|
|
|
|
func PostApiEmailSend(c *fiber.Ctx) error {
|
|
ctx := context.Background()
|
|
|
|
msg := email.EmailMessage{
|
|
To: c.FormValue("To"),
|
|
From: c.FormValue("From"),
|
|
Subject: c.FormValue("Subject"),
|
|
Text: c.FormValue("Message"),
|
|
HTML: c.FormValue("Message"),
|
|
}
|
|
|
|
sender := email.NewSender(ctx, email.Config{
|
|
RedisHostPort: "127.0.0.1:6379",
|
|
})
|
|
defer sender.Close()
|
|
|
|
err := sender.QueueEmail(msg)
|
|
if err != nil { return IfErrNil(err, c) }
|
|
|
|
return c.Redirect("/email/")
|
|
}
|
|
|
|
func SetupApi(app *fiber.App) {
|
|
app.Post("/api/email/send", PostApiEmailSend)
|
|
}
|
|
|