Documentation
¶
Index ¶
- type Attachment
- type Client
- func (c *Client) DeleteMessagePOP3(messageID int) error
- func (c *Client) GetUnreadCountIMAP(folder string) (int, error)
- func (c *Client) ReceiveIMAP(folder string, maxMessages int) ([]*Email, error)
- func (c *Client) ReceivePOP3(maxMessages int) ([]*Email, error)
- func (c *Client) Send(email *Email) error
- func (c *Client) SetAuth(username, password string) *Client
- func (c *Client) SetAuthType(authType string) *Client
- func (c *Client) SetIMAP(host string, port int) *Client
- func (c *Client) SetPOP3(host string, port int) *Client
- func (c *Client) SetRetry(maxRetries int, retryInterval time.Duration) *Client
- func (c *Client) SetSMTP(host string, port int) *Client
- func (c *Client) SetTLS(useTLS bool) *Client
- func (c *Client) SetTimeout(timeout time.Duration) *Client
- type Config
- type Email
- func (e *Email) AddAttachment(filename, contentType string, content []byte) *Email
- func (e *Email) AddAttachmentFromFile(filePath string) error
- func (e *Email) AddBcc(bcc ...string) *Email
- func (e *Email) AddCc(cc ...string) *Email
- func (e *Email) AddHeader(key, value string) *Email
- func (e *Email) AddTo(to ...string) *Email
- func (e *Email) SetBody(body string) *Email
- func (e *Email) SetFrom(from string) *Email
- func (e *Email) SetHTMLBody(htmlBody string) *Email
- func (e *Email) SetSentAt(sentAt time.Time) *Email
- func (e *Email) SetSubject(subject string) *Email
- func (e *Email) ToMIME() ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
Attachment 附件结构
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 邮件客户端
func NewClientWithConfig ¶
NewClientWithConfig 通过配置创建邮件客户端
func (*Client) DeleteMessagePOP3 ¶
DeleteMessagePOP3 通过POP3删除邮件
func (*Client) GetUnreadCountIMAP ¶
GetUnreadCountIMAP 获取未读邮件数量
func (*Client) ReceiveIMAP ¶
ReceiveIMAP 通过IMAP接收邮件
func (*Client) ReceivePOP3 ¶
ReceivePOP3 通过POP3接收邮件
func (*Client) SetAuthType ¶
SetAuthType 设置认证类型
type Config ¶
type Config struct {
SMTPHost string `yaml:"smtp_host" json:"smtp_host"`
SMTPPort int `yaml:"smtp_port" json:"smtp_port"`
POP3Host string `yaml:"pop3_host" json:"pop3_host"`
POP3Port int `yaml:"pop3_port" json:"pop3_port"`
IMAPHost string `yaml:"imap_host" json:"imap_host"`
IMAPPort int `yaml:"imap_port" json:"imap_port"`
Username string `yaml:"username" json:"username"`
Password string `yaml:"password" json:"password"`
UseTLS bool `yaml:"use_tls" json:"use_tls"`
AuthType string `yaml:"auth_type" json:"auth_type"` // "plain", "login", "cram-md5"
Timeout time.Duration `yaml:"timeout" json:"timeout"`
MaxRetries int `yaml:"max_retries" json:"max_retries"`
RetryInterval time.Duration `yaml:"retry_interval" json:"retry_interval"`
}
Config 邮件客户端配置
type Email ¶
type Email struct {
From string
To []string
Cc []string
Bcc []string
Subject string
Body string
HTMLBody string
Attachments []Attachment
Headers map[string]string
SentAt time.Time
}
Email 邮件结构
func (*Email) AddAttachment ¶
AddAttachment 添加附件
func (*Email) AddAttachmentFromFile ¶
AddAttachmentFromFile 从文件添加附件
func (*Email) SetHTMLBody ¶
SetHTMLBody 设置HTML正文
Click to show internal directories.
Click to hide internal directories.