Compare commits
No commits in common. "main" and "v1.1.1" have entirely different histories.
1 changed files with 13 additions and 3 deletions
16
smtp.go
16
smtp.go
|
@ -214,6 +214,7 @@ func (fr *Receiver) handleConnection(conn net.Conn) {
|
|||
|
||||
for {
|
||||
line, err := textProto.ReadLine()
|
||||
fmt.Println(line)
|
||||
if err != nil {
|
||||
_ = textProto.PrintfLine("421 4.7.0 Temporary server error")
|
||||
_ = conn.Close()
|
||||
|
@ -295,6 +296,8 @@ func (fr *Receiver) handleConnection(conn net.Conn) {
|
|||
}
|
||||
}
|
||||
case strings.HasPrefix(line, "AUTH"):
|
||||
fmt.Println("It's about time")
|
||||
|
||||
if !isSubmission {
|
||||
err = textProto.PrintfLine("503 5.5.1 AUTH only allowed on submission port")
|
||||
if err != nil {
|
||||
|
@ -326,7 +329,7 @@ func (fr *Receiver) handleConnection(conn net.Conn) {
|
|||
} else {
|
||||
checkAddress, err := fr.auth.Authenticate(strings.TrimPrefix(line, "AUTH "), textProto)
|
||||
if err != nil {
|
||||
_ = textProto.PrintfLine(err.Error())
|
||||
_ = textProto.PrintfLine("421 4.7.0 Temporary server error")
|
||||
_ = conn.Close()
|
||||
return
|
||||
}
|
||||
|
@ -590,6 +593,7 @@ func (fr *Receiver) handleConnection(conn net.Conn) {
|
|||
Host: strings.Split(conn.RemoteAddr().String(), ":")[0],
|
||||
}
|
||||
go sendEmail(SenderArgs{
|
||||
Hostname: fr.hostname,
|
||||
EnforceTLS: fr.enforceTLS,
|
||||
}, mail, fr.database, queueID)
|
||||
|
||||
|
@ -618,6 +622,7 @@ func (fr *Receiver) handleConnection(conn net.Conn) {
|
|||
|
||||
// SenderArgs is a struct that represents the arguments for the Sender
|
||||
type SenderArgs struct {
|
||||
Hostname string
|
||||
EnforceTLS bool
|
||||
}
|
||||
|
||||
|
@ -648,7 +653,7 @@ func Send(args SenderArgs, mail *Mail, conn net.Conn, mxHost string) (err error)
|
|||
return errors.New("unexpected greeting - " + line)
|
||||
}
|
||||
|
||||
err = textConn.PrintfLine("EHLO %s", mxHost)
|
||||
err = textConn.PrintfLine("EHLO %s", args.Hostname)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -682,11 +687,16 @@ func Send(args SenderArgs, mail *Mail, conn net.Conn, mxHost string) (err error)
|
|||
InsecureSkipVerify: false,
|
||||
})
|
||||
|
||||
err = tlsConn.Handshake()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
textConn = textproto.NewConn(tlsConn)
|
||||
|
||||
// Just use HELO, no point using EHLO when we already have all the capabilities
|
||||
// This also gets us out of using readMultilineCodeResponse
|
||||
err = textConn.PrintfLine("HELO %s", mxHost)
|
||||
err = textConn.PrintfLine("HELO %s", args.Hostname)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue