78 lines
2.9 KiB
Lua
78 lines
2.9 KiB
Lua
-- Message body chunks are written to `spamc` until the maximum message size is
|
||
-- reached, the rest is skipped (oversized messages are not processed by
|
||
-- SpamAssassin, so it is futile to send the whole message in this case).
|
||
|
||
local conn = mt.connect("inet:" .. port .. "@127.0.0.1")
|
||
assert(conn, "could not open connection")
|
||
|
||
local err = mt.conninfo(conn, "client.gluet.ch", "123.123.123.123")
|
||
assert(err == nil, err)
|
||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||
|
||
local err = mt.helo(conn, "mail.gluet.ch")
|
||
assert(err == nil, err)
|
||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||
|
||
local err = mt.mailfrom(conn, "from@gluet.ch")
|
||
assert(err == nil, err)
|
||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||
|
||
local err = mt.rcptto(conn, "to@gluet.ch")
|
||
assert(err == nil, err)
|
||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||
|
||
SMFIC_DATA = string.byte("T") -- SMFIC_DATA not exported by miltertest
|
||
local err = mt.macro(conn, SMFIC_DATA,
|
||
"i", "1234567ABC",
|
||
"j", "localhost",
|
||
"_", "client.gluet.ch [123.123.123.123]",
|
||
"{tls_version}", "TLSv1.2",
|
||
"v", "Postfix 3.3.0")
|
||
assert(err == nil, err)
|
||
|
||
local err = mt.data(conn)
|
||
assert(err == nil, err)
|
||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||
|
||
local err = mt.header(conn, "From", "from@gluet.ch")
|
||
assert(err == nil, err)
|
||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||
local err = mt.header(conn, "To", "to@gluet.ch")
|
||
assert(err == nil, err)
|
||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||
local err = mt.header(conn, "Subject", "Test message")
|
||
assert(err == nil, err)
|
||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||
local err = mt.header(conn, "Message-ID", string.format("<%06d@gluet.ch>", math.random(999999)))
|
||
assert(err == nil, err)
|
||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||
local err = mt.header(conn, "Date", os.date("%a, %d %b %Y %H:%M:%S %Z"))
|
||
assert(err == nil, err)
|
||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||
|
||
local err = mt.eoh(conn)
|
||
assert(err == nil, err)
|
||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||
|
||
-- At this point still below the size limit …
|
||
local err = mt.bodystring(conn, "Test message body")
|
||
assert(err == nil, err)
|
||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||
-- … after sending the following, we’re past the limit and skip.
|
||
local err = mt.bodystring(conn, [[
|
||
................................................................................
|
||
................................................................................
|
||
................................................................................
|
||
................................................................................
|
||
................................................................................
|
||
................................................................................
|
||
]])
|
||
assert(err == nil, err)
|
||
assert(mt.getreply(conn) == SMFIR_SKIP)
|
||
|
||
local err = mt.eom(conn)
|
||
assert(err == nil, err)
|
||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||
|
||
local err = mt.disconnect(conn)
|
||
assert(err == nil, err)
|