Documentation ¶
Overview ¶
Package mail implements an email sending API that uses MailGun and SendInBlue.
Index ¶
- Constants
- type ServiceMail
- type ServiceMailImpl
- func (s ServiceMailImpl) CheckPreconditions()
- func (s ServiceMailImpl) GenerateEmailTemplate(name string, templateName string) string
- func (s ServiceMailImpl) MakeSendInBlueRequest(ctx context.Context, data map[string]interface{}, target interface{}) error
- func (s ServiceMailImpl) SaveOutgoingEmails(ctx context.Context, payload *dto.OutgoingEmailsLog) error
- func (s ServiceMailImpl) SendEmail(ctx context.Context, subject, text string, body *string, to ...string) (string, string, error)
- func (s ServiceMailImpl) SendInBlue(ctx context.Context, subject, text string, to ...string) (string, string, error)
- func (s ServiceMailImpl) SendMailgun(ctx context.Context, subject, text string, body *string, to ...string) (string, string, error)
- func (s ServiceMailImpl) SimpleEmail(ctx context.Context, subject, text string, body *string, to ...string) (string, error)
- func (s ServiceMailImpl) UpdateMailgunDeliveryStatus(ctx context.Context, payload *dto.MailgunEvent) (*dto.OutgoingEmailsLog, error)
Constants ¶
const ( MailGunAPIKeyEnvVarName = "MAILGUN_API_KEY" MailGunAPIBaseURLEnvVarName = "MAILGUN_API_BASE_URL" MailGunDomainEnvVarName = "MAILGUN_DOMAIN" MailGunFromEnvVarName = "MAILGUN_FROM" MailGunTimeoutSeconds = 15 SendInBlueAPIKeyEnvVarName = "SEND_IN_BLUE_API_KEY" SendInBlueEnabledEnvVarName = "SEND_IN_BLUE_ENABLED" )
Mail configuration constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ServiceMail ¶
type ServiceMail interface { SendInBlue(ctx context.Context, subject, text string, to ...string) (string, string, error) SendMailgun( ctx context.Context, subject, text string, body *string, to ...string, ) (string, string, error) SendEmail( ctx context.Context, subject, text string, body *string, to ...string, ) (string, string, error) SimpleEmail( ctx context.Context, subject, text string, body *string, to ...string, ) (string, error) UpdateMailgunDeliveryStatus( ctx context.Context, payload *dto.MailgunEvent, ) (*dto.OutgoingEmailsLog, error) GenerateEmailTemplate(name string, templateName string) string }
ServiceMail defines a Mail service interface
type ServiceMailImpl ¶
type ServiceMailImpl struct { Mg *mailgun.MailgunImpl From string SendInBlueEnabled bool SendInBlueAPIKey string Repository database.Repository }
ServiceMailImpl is an email sending service
func NewService ¶
func NewService(repository database.Repository) *ServiceMailImpl
NewService initializes a new MailGun service
func (ServiceMailImpl) CheckPreconditions ¶
func (s ServiceMailImpl) CheckPreconditions()
CheckPreconditions checks that all the required preconditions are satisfied
func (ServiceMailImpl) GenerateEmailTemplate ¶
func (s ServiceMailImpl) GenerateEmailTemplate(name string, templateName string) string
GenerateEmailTemplate generates custom emails to be sent to the users
func (ServiceMailImpl) MakeSendInBlueRequest ¶
func (s ServiceMailImpl) MakeSendInBlueRequest( ctx context.Context, data map[string]interface{}, target interface{}, ) error
MakeSendInBlueRequest makes a request to SendInBlue
func (ServiceMailImpl) SaveOutgoingEmails ¶
func (s ServiceMailImpl) SaveOutgoingEmails(ctx context.Context, payload *dto.OutgoingEmailsLog) error
SaveOutgoingEmails saves all the outgoing emails
func (ServiceMailImpl) SendEmail ¶
func (s ServiceMailImpl) SendEmail( ctx context.Context, subject, text string, body *string, to ...string, ) (string, string, error)
SendEmail sends the specified email to the recipient(s) specified in `to` and returns the status
func (ServiceMailImpl) SendInBlue ¶
func (s ServiceMailImpl) SendInBlue( ctx context.Context, subject, text string, to ...string, ) (string, string, error)
SendInBlue sends email via the SendInBlue service
func (ServiceMailImpl) SendMailgun ¶
func (s ServiceMailImpl) SendMailgun( ctx context.Context, subject, text string, body *string, to ...string, ) (string, string, error)
SendMailgun sends email via MailGun
func (ServiceMailImpl) SimpleEmail ¶
func (s ServiceMailImpl) SimpleEmail( ctx context.Context, subject, text string, body *string, to ...string, ) (string, error)
SimpleEmail is a simplified API to send email. It returns only a status or error.
func (ServiceMailImpl) UpdateMailgunDeliveryStatus ¶
func (s ServiceMailImpl) UpdateMailgunDeliveryStatus( ctx context.Context, payload *dto.MailgunEvent, ) (*dto.OutgoingEmailsLog, error)
UpdateMailgunDeliveryStatus updates the status and delivery time of the sent email message