Documentation
¶
Index ¶
- Variables
- func BuildMimeMessage(message *EmailMessage) ([]byte, error)
- func GetMimeType(filename string) string
- func IsRetryableError(err error) bool
- func NewRetryableError(reason error) error
- func ValidateEmail(email string) string
- func ValidateEmailSlice(emails []string) []string
- type Attachment
- type EmailMessage
- type EmailSender
- type MessageOption
- func WithAttachment(attachment *Attachment) MessageOption
- func WithAttachments(attachments []*Attachment) MessageOption
- func WithBcc(bcc []string) MessageOption
- func WithCc(cc []string) MessageOption
- func WithFrom(from string) MessageOption
- func WithHTML(html string) MessageOption
- func WithHeader(key, value string) MessageOption
- func WithHeaderMap(headers map[string]string) MessageOption
- func WithHeaders(headers map[string]string) MessageOption
- func WithReplyTo(replyTo string) MessageOption
- func WithSubject(subject string) MessageOption
- func WithTag(tag Tag) MessageOption
- func WithTags(tags []Tag) MessageOption
- func WithText(text string) MessageOption
- func WithTo(to []string) MessageOption
- type Tag
Constants ¶
This section is empty.
Variables ¶
var ErrBatchNotImplemented = errors.New("batch email sending is not implemented for this provider")
ErrBatchNotImplemented is returned by providers that do not support native batch sending
Functions ¶
func BuildMimeMessage ¶
func BuildMimeMessage(message *EmailMessage) ([]byte, error)
BuildMimeMessage constructs the MIME message for the email, including text, HTML, and attachments
func GetMimeType ¶
GetMimeType returns the MIME type based on the file extension
func IsRetryableError ¶ added in v0.2.0
IsRetryableError checks if the error is retryable.
func NewRetryableError ¶ added in v0.2.0
NewRetryableError creates a new retryable error with a given reason.
func ValidateEmail ¶
ValidateEmail validates and sanitizes an email address
func ValidateEmailSlice ¶
ValidateEmailSlice validates and sanitizes a slice of email addresses
Types ¶
type Attachment ¶
type Attachment = shared.Attachment
Attachment represents an email attachment with its filename and content
func NewAttachment ¶
func NewAttachment(filename string, content []byte) *Attachment
NewAttachment creates a new Attachment instance with the specified filename and content
func NewAttachmentFromFile ¶
func NewAttachmentFromFile(filePath string) (*Attachment, error)
NewAttachmentFromFile creates a new Attachment instance from the specified file path
type EmailMessage ¶
type EmailMessage = shared.EmailMessage
EmailMessage represents an email message
func NewEmailMessage ¶
func NewEmailMessage(from string, to []string, subject string, body string) *EmailMessage
NewEmailMessage creates a new EmailMessage with the required fields
func NewEmailMessageWithOptions ¶ added in v0.1.1
func NewEmailMessageWithOptions(options ...MessageOption) *EmailMessage
NewEmailMessageWithOptions creates a new EmailMessage with the specified options
type EmailSender ¶
type EmailSender interface {
// SendEmail sends an email with the given message
SendEmail(message *EmailMessage) error
// SendEmailWithContext sends an email with the given message and context
SendEmailWithContext(ctx context.Context, message *EmailMessage) error
// SendBatchEmail sends a batch of emails with the given messages
SendBatchEmail(messages []*EmailMessage) error
// SendBatchEmailWithContext sends a batch of emails with the given messages and context
SendBatchEmailWithContext(ctx context.Context, messages []*EmailMessage) error
}
EmailSender interface defines the method to send an email
type MessageOption ¶ added in v0.1.1
type MessageOption func(*EmailMessage)
MessageOption is a function that sets a field on an EmailMessage
func WithAttachment ¶ added in v0.1.1
func WithAttachment(attachment *Attachment) MessageOption
WithAttachment adds an attachment to the email
func WithAttachments ¶ added in v0.1.1
func WithAttachments(attachments []*Attachment) MessageOption
WithAttachments sets the attachments of the email
func WithBcc ¶ added in v0.1.1
func WithBcc(bcc []string) MessageOption
WithBcc sets the bcc email address
func WithCc ¶ added in v0.1.1
func WithCc(cc []string) MessageOption
WithCc sets the cc email address
func WithFrom ¶ added in v0.1.1
func WithFrom(from string) MessageOption
WithFrom sets the from email address
func WithHTML ¶ added in v0.1.1
func WithHTML(html string) MessageOption
WithHTML sets the html content of the email
func WithHeader ¶ added in v0.1.1
func WithHeader(key, value string) MessageOption
WithHeader adds a header to the email
func WithHeaderMap ¶ added in v0.1.1
func WithHeaderMap(headers map[string]string) MessageOption
WithHeaderMap adds a map of headers to the email
func WithHeaders ¶ added in v0.1.1
func WithHeaders(headers map[string]string) MessageOption
WithHeaders sets the headers of the email
func WithReplyTo ¶ added in v0.1.1
func WithReplyTo(replyTo string) MessageOption
WithReplyTo sets the reply to email address
func WithSubject ¶ added in v0.1.1
func WithSubject(subject string) MessageOption
WithSubject sets the subject of the email
func WithTags ¶ added in v0.1.1
func WithTags(tags []Tag) MessageOption
WithTags sets the tags of the email
func WithText ¶ added in v0.1.1
func WithText(text string) MessageOption
WithText sets the text content of the email
func WithTo ¶ added in v0.1.1
func WithTo(to []string) MessageOption
WithTo sets the to email address
Directories
¶
| Path | Synopsis |
|---|---|
|
Package credentials is a helper to load credentials for respective email providers
|
Package credentials is a helper to load credentials for respective email providers |
|
Package providers are the vendor specific email senders
|
Package providers are the vendor specific email senders |
|
gmail
Package gmail is used for sending emails via gmail
|
Package gmail is used for sending emails via gmail |
|
mailgun
Package mailgun is used for sending emails via mailgun
|
Package mailgun is used for sending emails via mailgun |
|
mock
Package mock is for mocking the sending of emails, for testing and such
|
Package mock is for mocking the sending of emails, for testing and such |
|
postmark
Package postmark is used for sending emails via postmark
|
Package postmark is used for sending emails via postmark |
|
resend
Package resend is for sending emails via the resend api
|
Package resend is for sending emails via the resend api |
|
sendgrid
Package sendgrid is used for sending emails via sendgrid
|
Package sendgrid is used for sending emails via sendgrid |
|
smtp
Package smtp is used for sending emails via smtp
|
Package smtp is used for sending emails via smtp |
|
Package render provides themed email generation with CSS inlining, automatic plain text derivation, and markdown support
|
Package render provides themed email generation with CSS inlining, automatic plain text derivation, and markdown support |
|
Package scrubber is designed to be used in conjunction with the newman project for flexible email content sanitization
|
Package scrubber is designed to be used in conjunction with the newman project for flexible email content sanitization |
|
package shared provides utility functions and structures used across the newman project
|
package shared provides utility functions and structures used across the newman project |
