Fix the broken SMTP sending
This commit is contained in:
parent
1a1cc2a683
commit
50c83b08f0
27
smtp.go
27
smtp.go
|
@ -621,29 +621,9 @@ type SenderArgs struct {
|
||||||
EnforceTLS bool
|
EnforceTLS bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type DebugRWC struct {
|
|
||||||
net.Conn
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d DebugRWC) Write(p []byte) (n int, err error) {
|
|
||||||
fmt.Println("Write: ", string(p))
|
|
||||||
return d.Conn.Write(p)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d DebugRWC) Read(p []byte) (n int, err error) {
|
|
||||||
n, err = d.Conn.Read(p)
|
|
||||||
fmt.Println("Read: ", string(p))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d DebugRWC) Close() error {
|
|
||||||
fmt.Println("Close")
|
|
||||||
return d.Conn.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send sends an email to another server
|
// Send sends an email to another server
|
||||||
func Send(args SenderArgs, mail *Mail, conn net.Conn, mxHost string) (err error) {
|
func Send(args SenderArgs, mail *Mail, conn net.Conn, mxHost string) (err error) {
|
||||||
textConn := textproto.NewConn(DebugRWC{conn})
|
textConn := textproto.NewConn(conn)
|
||||||
|
|
||||||
err = textConn.PrintfLine("RSET")
|
err = textConn.PrintfLine("RSET")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -702,11 +682,6 @@ func Send(args SenderArgs, mail *Mail, conn net.Conn, mxHost string) (err error)
|
||||||
InsecureSkipVerify: false,
|
InsecureSkipVerify: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
err = tlsConn.Handshake()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
textConn = textproto.NewConn(tlsConn)
|
textConn = textproto.NewConn(tlsConn)
|
||||||
|
|
||||||
// Just use HELO, no point using EHLO when we already have all the capabilities
|
// Just use HELO, no point using EHLO when we already have all the capabilities
|
||||||
|
|
Loading…
Reference in New Issue