package email
import "git.sr.ht/~pingoo/stdx/email"
Package email provides an easy to use and hard to misuse email API
Index ¶
- Constants
- Variables
- func InitDefaultMailer(config SMTPConfig)
- func IsInBlocklist(email string) bool
- func Send(email Email) error
- type Attachment
- type Email
- type Mailer
- type SMTPConfig
- type SMTPMailer
Constants ¶
const ( // MaxLineLength is the maximum line length per RFC 2045 MaxLineLength = 76 )
Variables ¶
var BlocklistBytes []byte
ErrMissingBoundary is returned when there is no boundary given for a multipart entity
ErrMissingContentType is returned when there is no "Content-Type" header for a MIME entity
Functions ¶
func InitDefaultMailer ¶
func InitDefaultMailer(config SMTPConfig)
InitDefaultMailer set the default, global mailer
func IsInBlocklist ¶
func Send ¶
Send an email using the default mailer
Types ¶
type Attachment ¶
type Attachment struct { Filename string Header textproto.MIMEHeader Content []byte }
Attachment is an email attachment. Based on the mime/multipart.FileHeader struct, Attachment contains the name, MIMEHeader, and content of the attachment in question
type Email ¶
type Email struct { ReplyTo []mail.Address From mail.Address To []mail.Address Bcc []mail.Address Cc []mail.Address Subject string Text []byte // Plaintext message HTML []byte // Html message Headers textproto.MIMEHeader Attachments []Attachment }
Email is an email... either Text or HTML must be provided
func (*Email) Bytes ¶
Bytes returns the content of the email in the bytes form
type Mailer ¶
type Mailer interface { SendTransactionnal(ctx context.Context, email Email) error SendBroadcast(ctx context.Context, email Email) error }
Mailer is the interface defining a service which sends emails
type SMTPConfig ¶
SMTPConfig is used to configure an email
type SMTPMailer ¶
type SMTPMailer struct {
// contains filtered or unexported fields
}
Mailer are used to send email
func NewSMTPMailer ¶
func NewSMTPMailer(config SMTPConfig) SMTPMailer
NewMailer returns a new mailer
func (*SMTPMailer) Send ¶
func (mailer *SMTPMailer) Send(email Email) error
Send an email
Source Files ¶
blocklist.go email.go mailer.go
Directories ¶
Path | Synopsis |
---|---|
email/console | |
email/postmark | |
email/scaleway | |
email/ses | |
email/smtp |
- Version
- v0.0.0-20240218134121-094174641f6e (latest)
- Published
- Feb 18, 2024
- Platform
- linux/amd64
- Imports
- 17 packages
- Last checked
- 4 months ago –
Tools for package owners.