mirror of
https://github.com/1f349/lotus.git
synced 2024-11-09 22:52:53 +00:00
46 lines
840 B
Go
46 lines
840 B
Go
package fake
|
|
|
|
import (
|
|
"github.com/emersion/go-smtp"
|
|
"io"
|
|
"log"
|
|
)
|
|
|
|
type SmtpBackend struct {
|
|
Debug chan []byte
|
|
}
|
|
|
|
func (f *SmtpBackend) NewSession(c *smtp.Conn) (smtp.Session, error) {
|
|
return &SmtpSession{f.Debug}, nil
|
|
}
|
|
|
|
type SmtpSession struct {
|
|
Debug chan []byte
|
|
}
|
|
|
|
func (f *SmtpSession) Reset() {}
|
|
|
|
func (f *SmtpSession) Logout() error { return nil }
|
|
|
|
func (f *SmtpSession) AuthPlain(username, password string) error { return nil }
|
|
|
|
func (f *SmtpSession) Mail(from string, opts *smtp.MailOptions) error {
|
|
log.Println("MAIL " + from)
|
|
f.Debug <- []byte("MAIL " + from + "\n")
|
|
return nil
|
|
}
|
|
|
|
func (f *SmtpSession) Rcpt(to string) error {
|
|
f.Debug <- []byte("RCPT " + to + "\n")
|
|
return nil
|
|
}
|
|
|
|
func (f *SmtpSession) Data(r io.Reader) error {
|
|
all, err := io.ReadAll(r)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
f.Debug <- all
|
|
return nil
|
|
}
|