Expanded mail client for easier email operations.

This commit is contained in:
mikestefanello 2022-01-14 15:42:32 -05:00
parent b269e7d264
commit cb43e08183
5 changed files with 160 additions and 59 deletions

View file

@ -1,6 +1,8 @@
package routes
import (
"fmt"
"github.com/mikestefanello/pagoda/context"
"github.com/mikestefanello/pagoda/controller"
@ -47,7 +49,14 @@ func (c *Contact) Post(ctx echo.Context) error {
}
if !form.Submission.HasErrors() {
if err := c.Container.Mail.Send(ctx, form.Email, "Hello!"); err != nil {
err := c.Container.Mail.
Compose().
To(form.Email).
Subject("Contact form submitted").
Body(fmt.Sprintf("The message is: %s", form.Message)).
Send(ctx)
if err != nil {
return c.Fail(ctx, err, "unable to send email")
}
}