1//go:build integration2// +build integration34/*5Maddy Mail Server - Composable all-in-one email server.6Copyright © 2019-2020 Max Mazurov <fox.cpp@disroot.org>, Maddy Mail Server contributors78This program is free software: you can redistribute it and/or modify9it under the terms of the GNU General Public License as published by10the Free Software Foundation, either version 3 of the License, or11(at your option) any later version.1213This program is distributed in the hope that it will be useful,14but WITHOUT ANY WARRANTY; without even the implied warranty of15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16GNU General Public License for more details.1718You should have received a copy of the GNU General Public License19along with this program. If not, see <https://www.gnu.org/licenses/>.20*/2122package tests_test2324import (25 "strconv"26 "testing"27 "time"2829 "github.com/foxcpp/maddy/internal/testutils"30 "github.com/foxcpp/maddy/tests"31)3233func TestIssue327(tt *testing.T) {34 tt.Parallel()35 t := tests.NewT(tt)36 t.DNS(nil)37 t.Port("smtp")38 tgtPort := t.Port("target")39 t.Config(`40 hostname mx.maddy.test41 tls off42 smtp tcp://127.0.0.1:{env:TEST_PORT_smtp} {43 deliver_to queue outbound_queue {44 target remote { } # it will fail45 autogenerated_msg_domain maddy.test46 bounce {47 check {48 spf49 }50 deliver_to lmtp tcp://127.0.0.1:{env:TEST_PORT_target}51 }52 }53 }`)54 t.Run(1)55 defer t.Close()5657 be, s := testutils.SMTPServer(tt, "127.0.0.1:"+strconv.Itoa(int(tgtPort)))58 s.LMTP = true59 be.LMTPDataErr = []error{nil, nil}60 defer s.Close()6162 c := t.Conn("smtp")63 defer c.Close()64 c.SMTPNegotation("client.maddy.test", nil, nil)65 c.Writeln("MAIL FROM:<from@maddy.test>")66 c.ExpectPattern("250 *")67 c.Writeln("RCPT TO:<to1@maddy.test>")68 c.ExpectPattern("250 *")69 c.Writeln("DATA")70 c.ExpectPattern("354 *")71 c.Writeln("From: <from@maddy.test>")72 c.Writeln("To: <to@maddy.test>")73 c.Writeln("Subject: Hello!")74 c.Writeln("")75 c.Writeln("Hello!")76 c.Writeln(".")77 c.ExpectPattern("250 2.0.0 OK: queued")78 c.Writeln("QUIT")79 c.ExpectPattern("221 *")8081 for i := 0; i < 5; i++ {82 time.Sleep(1 * time.Second)83 if len(be.Messages) != 0 {84 break85 }86 }8788 if len(be.Messages) != 1 {89 t.Fatal("No DSN sent?", len(be.Messages))90 }91}