Documentation
¶
Index ¶
- Variables
- func ProvideSender(cfg *Email) (*senderWrapper, error)
- type AliyunConfig
- type AliyunSender
- type Config
- type Email
- type LocalSMTPSender
- type MailgunConfig
- type MailgunSender
- type NetEaseConfig
- type NetEaseSender
- type SMTPConfig
- type SendGridConfig
- type SendGridSender
- type Sender
- type Template
- type TencentCloudConfig
- type TencentCloudSender
Constants ¶
This section is empty.
Variables ¶
var ProviderSet = wire.NewSet( ProvideSender, wire.Bind(new(Sender), new(*senderWrapper)), )
ProviderSet is the wire provider set for the email package. It provides email Sender for sending emails through various providers.
Usage:
wire.Build(
email.ProviderSet,
// ... other providers
)
Functions ¶
func ProvideSender ¶ added in v0.2.0
ProvideSender creates an email Sender from Email configuration. Returns nil if no valid configuration is provided.
Types ¶
type AliyunConfig ¶
AliyunConfig holds the configuration for Aliyun DirectMail
type AliyunSender ¶
type AliyunSender struct {
Config *AliyunConfig
}
AliyunSender implements EmailSender for Aliyun
func (*AliyunSender) SendTemplateEmail ¶
func (s *AliyunSender) SendTemplateEmail(recipientEmail string, template Template) (string, error)
type Email ¶
type Email struct {
Provider string `json:"provider" yaml:"provider"`
Mailgun *MailgunConfig `json:"mailgun" yaml:"mailgun"`
Aliyun *AliyunConfig `json:"aliyun" yaml:"aliyun"`
NetEase *NetEaseConfig `json:"netease" yaml:"netease"`
SendGrid *SendGridConfig `json:"sendgrid" yaml:"sendgrid"`
SMTP *SMTPConfig `json:"smtp" yaml:"smtp"`
TencentCloud *TencentCloudConfig `json:"tencent_cloud" yaml:"tencent_cloud"`
}
Email holds the configuration for all email providers
type LocalSMTPSender ¶
type LocalSMTPSender struct {
Config *SMTPConfig
}
LocalSMTPSender implements EmailSender for local SMTP
func (*LocalSMTPSender) SendTemplateEmail ¶
func (s *LocalSMTPSender) SendTemplateEmail(recipientEmail string, template Template) (string, error)
type MailgunConfig ¶
MailgunConfig holds the configuration for Mailgun
type MailgunSender ¶
type MailgunSender struct {
Config *MailgunConfig
}
MailgunSender implements EmailSender for Mailgun
func (*MailgunSender) SendTemplateEmail ¶
func (s *MailgunSender) SendTemplateEmail(recipientEmail string, template Template) (string, error)
type NetEaseConfig ¶
type NetEaseConfig struct {
Username string
Password string
From string
SMTPHost string
SMTPPort string
}
NetEaseConfig holds the configuration for NetEase Enterprise Email
type NetEaseSender ¶
type NetEaseSender struct {
Config *NetEaseConfig
}
NetEaseSender implements EmailSender for NetEase
func (*NetEaseSender) SendTemplateEmail ¶
func (s *NetEaseSender) SendTemplateEmail(recipientEmail string, template Template) (string, error)
type SMTPConfig ¶
type SMTPConfig struct {
SMTPHost string
SMTPPort string
Username string
Password string
From string
}
SMTPConfig holds the configuration for local email sending
type SendGridConfig ¶
SendGridConfig holds the configuration for SendGrid
type SendGridSender ¶
type SendGridSender struct {
Config *SendGridConfig
}
SendGridSender implements EmailSender for SendGrid
func (*SendGridSender) SendTemplateEmail ¶
func (s *SendGridSender) SendTemplateEmail(recipientEmail string, template Template) (string, error)
type Sender ¶
type Sender interface {
SendTemplateEmail(recipientEmail string, template Template) (string, error)
}
Sender is a generic interface for sending emails
func ProvideMailgunSender ¶ added in v0.2.0
func ProvideMailgunSender(cfg *MailgunConfig) (Sender, error)
ProvideMailgunSender creates a Mailgun email sender.
func ProvideSMTPSender ¶ added in v0.2.0
func ProvideSMTPSender(cfg *SMTPConfig) (Sender, error)
ProvideSMTPSender creates an SMTP email sender.
func ProvideSendGridSender ¶ added in v0.2.0
func ProvideSendGridSender(cfg *SendGridConfig) (Sender, error)
ProvideSendGridSender creates a SendGrid email sender.
type Template ¶
type Template struct {
Subject string `json:"subject"`
Template string `json:"template"`
Keyword string `json:"keyword"`
URL string `json:"url"`
Data any `json:"data"`
}
Template represents the email template
type TencentCloudConfig ¶
TencentCloudConfig holds the configuration for Tencent Cloud Simple Email Service
type TencentCloudSender ¶
type TencentCloudSender struct {
Config *TencentCloudConfig
}
TencentCloudSender implements EmailSender for Tencent Cloud
func (*TencentCloudSender) SendTemplateEmail ¶
func (s *TencentCloudSender) SendTemplateEmail(recipientEmail string, template Template) (string, error)