email

package
v0.0.0-...-0d7d7e8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2025 License: MIT Imports: 8 Imported by: 0

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 IsValid

func IsValid(email string) bool

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

type Service interface {
	Send(emailTo, subject, plainTextContent, htmlContent string) error
}

Service defines the interface for handling emails

func NewSendgridService

func NewSendgridService() Service

NewSendgridService returns a new instance of SendgridService

func S

func S() Service

S is used to access the global service singleton

Directories

Path Synopsis
Package templates provides functionality for managing email templates.
Package templates provides functionality for managing email templates.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL