package controllers import ( "clapclap/internal/apperr" "clapclap/internal/email" "net/http" "github.com/gin-gonic/gin" ) // TODO: (loic) move that from public doc // TestMail godoc // @Summary Test Email Service // @Description Sends a test email to verify SMTP configuration // @Tags test // @Produce json // @Success 200 {object} swaggMessageResponse // @Failure 500 {object} map[string]interface{} // @Router /test/mail [get] func TestMail(c *gin.Context) { myEmail := email.Email{ To: "detafe6383@deapad.com", Subject: "WOW IT WORKS HELLO MAMA", // Use HTML tags instead of \n\n Content: "
This email was sent using a reusable Go function and a .env file.
It works perfectly!
", } // Capture the error here err := email.Send(myEmail) if err != nil { apperr.AbortWithError(c, apperr.NewInternalServerError(err, "Failed to send email")) return } c.JSON(http.StatusOK, gin.H{"message": "MAIL SENT"}) }