@@ -636,6 +636,45 @@ func TestServer_LFDotLF(t *testing.T) {
636636 }
637637}
638638
639+ func TestServer_EmptyMessage (t * testing.T ) {
640+ be , s , c , scanner := testServerAuthenticated (t )
641+ defer s .Close ()
642+ defer c .Close ()
643+
644+ io .
WriteString (
c ,
"MAIL FROM:<[email protected] >\r \n " )
645+ scanner .Scan ()
646+ if ! strings .HasPrefix (scanner .Text (), "250 " ) {
647+ t .Fatal ("Invalid MAIL response:" , scanner .Text ())
648+ }
649+
650+ io .
WriteString (
c ,
"RCPT TO:<[email protected] >\r \n " )
651+ scanner .Scan ()
652+ if ! strings .HasPrefix (scanner .Text (), "250 " ) {
653+ t .Fatal ("Invalid RCPT response:" , scanner .Text ())
654+ }
655+
656+ io .WriteString (c , "DATA\r \n " )
657+ scanner .Scan ()
658+ if ! strings .HasPrefix (scanner .Text (), "354 " ) {
659+ t .Fatal ("Invalid DATA response:" , scanner .Text ())
660+ }
661+
662+ io .WriteString (c , "\r \n \r \n .\r \n " )
663+ scanner .Scan ()
664+ if ! strings .HasPrefix (scanner .Text (), "250 " ) {
665+ t .Fatal ("Invalid DATA response:" , scanner .Text ())
666+ }
667+
668+ if len (be .messages ) != 1 || len (be .anonmsgs ) != 0 {
669+ t .Fatal ("Invalid number of sent messages:" , be .messages , be .anonmsgs )
670+ }
671+
672+ msg := be .messages [0 ]
673+ if string (msg .Data ) != "\r \n \r \n " {
674+ t .Fatal ("Invalid mail data:" , string (msg .Data ), msg .Data )
675+ }
676+ }
677+
639678func TestServer_authDisabled (t * testing.T ) {
640679 _ , s , c , scanner , caps := testServerEhlo (t , authDisabled )
641680 defer s .Close ()
0 commit comments