-- usage: -- miltertest -s opendkim-testmilter.lua -D socket=local:/var/spool/postfix/opendkim/opendkim.sock -D host=localhost -D ip=127.0.0.1 -D from=test@linuxhotel.de -- TODO: auth_type conn = mt.connect(socket) if conn == nil then error "mt.connect() failed" else msg = "connected to " .. socket print(msg) end conninfo = mt.conninfo(conn, host, ip) if conninfo ~= nil then error "mt.conninfo() failed" else msg = "send connection info - host: " .. host .. ", ip: " .. ip print(msg) end print("") print("send envelope macros and sender data") -- mt.helo() is called implicitly -- TODO: auth_type mt.macro(conn, SMFIC_MAIL, "i", "test-id") if mt.mailfrom(conn, from) ~= nil then error "mt.mailfrom() failed" else msg = "send mailfrom " .. from print(msg) end if mt.getreply(conn) ~= SMFIR_CONTINUE then error "mt.mailfrom() unexpected reply" end print("") print("send headers") if mt.header(conn, "From", from) ~= nil then error "mt.header(From) failed" else msg = "send From: " .. from print(msg) end -- send EOH if mt.eoh(conn) ~= nil then error "mt.eoh() failed" end if mt.getreply(conn) ~= SMFIR_CONTINUE then error "mt.eoh() unexpected reply" end if mt.eom(conn) ~= nil then error "mt.eom() failed" end if mt.getreply(conn) ~= SMFIR_ACCEPT then error "mt.eom() unexpected reply" end print("") -- verify that a test header field got added -- if mt.eom_check(conn, MT_HDRADD) then -- print("Header added") -- else -- error "no Header added" -- end if mt.eom_check(conn, MT_HDRINSERT, "DKIM-Signature") then print("DKIM-Signature added") else error "no DKIM-Signature added" end -- wrap it up! mt.disconnect(conn)