|
|
|
|
@ -2,29 +2,18 @@ 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{ |
|
|
|
|
func PostApiEmailSend(c *fiber.Ctx) error { |
|
|
|
|
go email.OneShotSend(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/") |
|
|
|
|
} |
|
|
|
|
|