Documentation
¶
Overview ¶
Package email provides functionality for sending emails.
This package defines an interface for email services, allowing for different implementations. The default implementation uses the SendGrid service to send emails.
In your main.go or application initialization file, you can initialize the email service like this:
package main import ( "github.com/Zapharaos/fihub-backend/pkg/email" ) func main() { // Initialize the email service emailService := email.NewSendgridService() // Replace the global email service instance email.ReplaceGlobals(emailService) }
To send an email:
err := service.Send("recipient@example.com", "Subject", "Plain text content", "HTML content")
For more information, see the documentation for the SendGrid library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReplaceGlobals ¶
func ReplaceGlobals(service Service) func()
ReplaceGlobals affect a new repository to the global service singleton
Types ¶
type SendgridClient ¶
type SendgridClient interface { Send(email *mail.SGMailV3) (*rest.Response, error) SendWithContext(ctx context.Context, email *mail.SGMailV3) (*rest.Response, error) }
SendgridClient is an interface for sending emails
type SendgridService ¶
type SendgridService struct {
// contains filtered or unexported fields
}
SendgridService implements the Service interface using SendGrid
func (*SendgridService) Send ¶
func (s *SendgridService) Send(emailTo, subject, plainTextContent, htmlContent string) error
Send sends an email using SendGrid
type Service ¶
Service defines the interface for handling emails
func NewSendgridService ¶
func NewSendgridService() Service
NewSendgridService returns a new instance of SendgridService