mirror of
https://github.com/axllent/mailpit.git
synced 2025-04-23 12:18:56 +02:00
Fix: Correctly detect maximum SMTP recipient limits, add test
This commit is contained in:
parent
703e981a8b
commit
1db502ef4e
@ -362,6 +362,11 @@ func (s *session) serve() {
|
|||||||
var to []string
|
var to []string
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
|
|
||||||
|
// RFC 5321 specifies support for minimum of 100 recipients is required.
|
||||||
|
if s.srv.MaxRecipients == 0 {
|
||||||
|
s.srv.MaxRecipients = 100
|
||||||
|
}
|
||||||
|
|
||||||
// Send banner.
|
// Send banner.
|
||||||
s.writef("220 %s %s ESMTP Service ready", s.srv.Hostname, s.srv.AppName)
|
s.writef("220 %s %s ESMTP Service ready", s.srv.Hostname, s.srv.AppName)
|
||||||
|
|
||||||
@ -474,12 +479,7 @@ loop:
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// RFC 5321 specifies support for minimum of 100 recipients is required.
|
if len(to) >= s.srv.MaxRecipients {
|
||||||
if s.srv.MaxRecipients == 0 {
|
|
||||||
s.srv.MaxRecipients = 100
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(to) == s.srv.MaxRecipients {
|
|
||||||
s.writef("452 4.5.3 Too many recipients")
|
s.writef("452 4.5.3 Too many recipients")
|
||||||
} else {
|
} else {
|
||||||
accept := true
|
accept := true
|
||||||
|
@ -242,6 +242,23 @@ func TestCmdRCPT(t *testing.T) {
|
|||||||
conn.Close()
|
conn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCmdMaxRecipients(t *testing.T) {
|
||||||
|
conn := newConn(t, &Server{MaxRecipients: 3})
|
||||||
|
|
||||||
|
cmdCode(t, conn, "EHLO host.example.com", "250")
|
||||||
|
|
||||||
|
cmdCode(t, conn, "MAIL FROM:<sender@example.com>", "250")
|
||||||
|
|
||||||
|
cmdCode(t, conn, "RCPT TO: <recipient1@example.com>", "250")
|
||||||
|
cmdCode(t, conn, "RCPT TO: <recipient2@example.com>", "250")
|
||||||
|
cmdCode(t, conn, "RCPT TO: <recipient3@example.com>", "250")
|
||||||
|
cmdCode(t, conn, "RCPT TO: <recipient4@example.com>", "452")
|
||||||
|
cmdCode(t, conn, "RCPT TO: <recipient5@example.com>", "452")
|
||||||
|
|
||||||
|
cmdCode(t, conn, "QUIT", "221")
|
||||||
|
conn.Close()
|
||||||
|
}
|
||||||
|
|
||||||
func TestCmdDATA(t *testing.T) {
|
func TestCmdDATA(t *testing.T) {
|
||||||
conn := newConn(t, &Server{})
|
conn := newConn(t, &Server{})
|
||||||
cmdCode(t, conn, "EHLO host.example.com", "250")
|
cmdCode(t, conn, "EHLO host.example.com", "250")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user