@@ -1002,6 +1002,10 @@ func (s *SmtpSession) readClientLine() (string, error) {
10021002
10031003 line , err := s .clientReader .ReadString ('\n' )
10041004
1005+ if err == io .EOF {
1006+ err = nil
1007+ }
1008+
10051009 if gLogLevel >= LOG_DEBUG {
10061010 s .logf (LOG_DEBUG , "C> %q" , line )
10071011 }
@@ -1014,6 +1018,10 @@ func (s *SmtpSession) readUpstreamLine() (string, error) {
10141018
10151019 line , err := s .upstreamReader .ReadString ('\n' )
10161020
1021+ if err == io .EOF {
1022+ err = nil
1023+ }
1024+
10171025 if gLogLevel >= LOG_DEBUG {
10181026 s .logf (LOG_DEBUG , "U> %q" , line )
10191027 }
@@ -1098,6 +1106,7 @@ func (s *SmtpSession) connectUpstream() error {
10981106 s .upstreamReader = bufio .NewReader (tlsConn )
10991107
11001108 _ , err = s .readUpstreamLine ()
1109+
11011110 if err != nil {
11021111 s .logf (LOG_ERROR , "Cannot read from upstream connection [%s]: %v" , target , err )
11031112 tlsConn .Close ()
@@ -1245,6 +1254,11 @@ func (s *SmtpSession) handleEHLO(line string) error {
12451254
12461255 for {
12471256 resp , err := s .readUpstreamLine ()
1257+
1258+ if err == io .EOF {
1259+ err = nil
1260+ }
1261+
12481262 if err != nil {
12491263 return err
12501264 }
@@ -1381,6 +1395,7 @@ func (s *SmtpSession) sendXCLIENT() {
13811395 }
13821396
13831397 resp , err := s .readUpstreamLine ()
1398+
13841399 if err != nil || ! strings .HasPrefix (resp , "2" ) {
13851400 s .logf (LOG_ERROR , "Upstream rejected XCLIENT: %s" , resp )
13861401 }
@@ -1554,7 +1569,9 @@ func (s *SmtpSession) run() {
15541569 // Read and forward response(including multi-line responses
15551570
15561571 for {
1572+
15571573 resp , err := s .readUpstreamLine ()
1574+
15581575 if err != nil {
15591576 s .logf (LOG_ERROR , "Cannot read Upstream response: %v" , err )
15601577 return
0 commit comments