dsn-processor/tests/miltertest_multi.lua
2023-12-10 01:04:42 +01:00

70 lines
1.8 KiB
Lua

-- https://mopano.github.io/sendmail-filter-api/constant-values.html#com.sendmail.milter.MilterConstants
-- http://www.opendkim.org/miltertest.8.html
conn = mt.connect("inet:4321@127.0.0.1")
if conn == nil then
error "mt.connect() failed"
end
if mt.conninfo(conn, "localhost", "::1") ~= nil then
error "mt.conninfo() failed"
end
mt.set_timeout(3)
-- 5321.FROM
if mt.mailfrom(conn, "<>") ~= nil then
error "mt.mailfrom() failed"
end
if mt.getreply(conn) ~= SMFIR_CONTINUE then
error "mt.mailfrom() unexpected reply"
end
-- 5321.RCPT+MACROS
mt.macro(conn, SMFIC_RCPT, "i", "4CgSNs5Q9sz7SllQ")
if mt.rcptto(conn, "<some-id-stuff@example.com>") ~= nil then
error "mt.rcptto() failed"
end
if mt.getreply(conn) ~= SMFIR_CONTINUE then
error "mt.rcptto() unexpected reply"
end
--mt.data(conn)
-- HEADERS
if mt.header(conn, "From", '"MAILER DAEMON" <bouncer@blah.blubb>') ~= nil then
error "mt.header(From) failed"
end
if mt.header(conn, "MIME-Version", "1.0") ~= nil then
error "mt.header(MIME-Version) failed"
end
if mt.header(conn, "Content-Type", "multipart/report; report-type=delivery-status;\n\tboundary=\"JAA13167.773673707/CS.UTK.EDU\"") ~= nil then
error "mt.header(Content-Type) failed"
end
-- BODY
if mt.bodyfile(conn, "MULTI_body.txt") ~= nil then
error "mt.bodyfile() failed"
end
if mt.getreply(conn) ~= SMFIR_CONTINUE then
error "mt.bodyfile() unexpected reply"
end
-- EOM
if mt.eom(conn) ~= nil then
error "mt.eom() failed"
end
mt.echo("EOM: " .. mt.getreply(conn))
if mt.getreply(conn) == SMFIR_CONTINUE then
mt.echo("EOM-continue")
elseif mt.getreply(conn) == SMFIR_REPLYCODE then
mt.echo("EOM-reject")
end
if not mt.eom_check(conn, MT_HDRADD, "X-ExOTA-Authentication-Results") then
mt.echo("no header added")
else
mt.echo("X-ExOTA-Authentication-Results header added")
end
-- DISCONNECT
mt.disconnect(conn)