smtpserver

package
v0.0.0-...-9b19cff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

这个文件实现了 SMTP 服务器的功能。 它实现了 Backend 结构,该结构包含一个 Save 方法,该方法用于保存邮件。 它还实现了 NewBackend 方法,该方法用于创建 Backend 实例。 它还实现了 NewSession 方法,该方法用于创建 Session 实例。 Session 结构包含一个 Backend 实例,From、To、RawData 字段,以及 Save 方法。 该方法用于保存邮件。 其他方法实现了 SMTP 服务器的功能。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	Save func(string, []string, []byte) //数据存储函数
}

The Backend implements SMTP server methods.

func (*Backend) ListenAndServe

func (bkd *Backend) ListenAndServe(option ...func(*smtp.Server))

func (*Backend) NewBackend

func (bkd *Backend) NewBackend(fun func(string, []string, []byte)) *Backend

func (*Backend) NewSession

func (bkd *Backend) NewSession(c *smtp.Conn) (smtp.Session, error)

NewSession is called after client greeting (EHLO, HELO).

type Sender

type Sender interface {
	Open() error
	Close()
	Send([]msg) ([]any, error)
}

type Session

type Session struct {
	From    string
	To      []string
	RawData []byte

	Save func(string, []string, []byte)
}

A Session is returned after successful login.

func (*Session) Data

func (s *Session) Data(r io.Reader) error

func (*Session) Logout

func (s *Session) Logout() error

func (*Session) Mail

func (s *Session) Mail(from string, opts *smtp.MailOptions) error

func (*Session) Rcpt

func (s *Session) Rcpt(to string, opts *smtp.RcptOptions) error

func (*Session) Reset

func (s *Session) Reset()

type SimpleSender

type SimpleSender struct {
	DSN string

	*smtp.Client
}

SimpleSender is a simple implementation of the Sender interface.

func (*SimpleSender) Close

func (s *SimpleSender) Close()

func (*SimpleSender) Open

func (s *SimpleSender) Open() error

func (*SimpleSender) Send

func (s *SimpleSender) Send(m msg) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL