Browse Source

close smtpReader after finishing reading from the DATA command

flashmob 5 years ago
parent
commit
219b14ab95
2 changed files with 8 additions and 3 deletions
  1. 4 3
      chunk/chunk_test.go
  2. 4 0
      server.go

+ 4 - 3
chunk/chunk_test.go

@@ -610,8 +610,9 @@ func initTestStream(transform bool) (*StoreMemory, *backends.StreamDecorator, *b
 	// place the parse result in an envelope
 	e := mail.NewEnvelope("127.0.0.1", 1)
 	to, _ := mail.NewAddress("[email protected]")
-	e.RcptTo = append(e.RcptTo, to)
-	e.MailFrom, _ = mail.NewAddress("[email protected]")
+	e.RcptTo = append(e.RcptTo, *to)
+	from, _ := mail.NewAddress("[email protected]")
+	e.MailFrom = *from
 	store := new(StoreMemory)
 	chunkBuffer := NewChunkedBytesBufferMime()
 	//chunkBuffer.setDatabase(store)
@@ -631,7 +632,7 @@ func initTestStream(transform bool) (*StoreMemory, *backends.StreamDecorator, *b
 			transformer.Decorate(
 				//debug.Decorate(
 				chunksaver.Decorate(
-					backends.DefaultStreamProcessor{}, store, chunkBuffer))) //)
+					backends.DefaultStreamProcessor{}, store, chunkBuffer)))
 	} else {
 		stream = mimeanalyzer.Decorate(
 			//debug.Decorate(

+ 4 - 0
server.go

@@ -606,6 +606,10 @@ func (s *server) handleClient(client *client) {
 						client.Envelope.Header = p[0].Headers
 					}
 				}
+				// All done. we can close the smtpReader, the protocol will reset the transaction, expecting a new message
+				if err := client.smtpReader.Close(); err != nil {
+					s.log().WithError(err).Error("could not close DATA reader")
+				}
 			}
 
 			if err != nil {