@@ -733,6 +733,37 @@ func TestServer_tooLongMessage(t *testing.T) {
733
733
}
734
734
}
735
735
736
+ // See https://www.postfix.org/smtp-smuggling.html
737
+ func TestServer_smtpSmuggling (t * testing.T ) {
738
+ be , s , c , scanner := testServerAuthenticated (t )
739
+ defer s .Close ()
740
+
741
+ io .
WriteString (
c ,
"MAIL FROM:<[email protected] >\r \n " )
742
+ scanner .Scan ()
743
+ io .
WriteString (
c ,
"RCPT TO:<[email protected] >\r \n " )
744
+ scanner .Scan ()
745
+ io .WriteString (c , "DATA\r \n " )
746
+ scanner .Scan ()
747
+
748
+ io .WriteString (c , "This is a message with an SMTP smuggling dot:\r \n " )
749
+ io .WriteString (c , ".\n " )
750
+ io .WriteString (c , "Final dot comes after.\r \n " )
751
+ io .WriteString (c , ".\r \n " )
752
+ scanner .Scan ()
753
+ if ! strings .HasPrefix (scanner .Text (), "250 " ) {
754
+ t .Fatal ("Invalid DATA response, expected an error but got:" , scanner .Text ())
755
+ }
756
+
757
+ if len (be .messages ) != 1 {
758
+ t .Fatal ("Invalid number of sent messages:" , len (be .messages ))
759
+ }
760
+
761
+ msg := be .messages [0 ]
762
+ if string (msg .Data ) != "This is a message with an SMTP smuggling dot:\r \n \n Final dot comes after.\r \n " {
763
+ t .Fatalf ("Invalid mail data: %q" , string (msg .Data ))
764
+ }
765
+ }
766
+
736
767
func TestServer_tooLongLine (t * testing.T ) {
737
768
_ , s , c , scanner := testServerAuthenticated (t )
738
769
defer s .Close ()
0 commit comments