public interface IMilterHandler
Modifier and Type | Method and Description |
---|---|
IMilterStatus |
abort()
Handle the current message being aborted.
|
IMilterStatus |
body(ByteBuffer bodyp)
Handle a piece of a message's body.
|
IMilterStatus |
close()
The current connection is being closed.
|
IMilterStatus |
connect(String hostname,
InetAddress hostaddr,
Properties properties)
Called once at the start of each SMTP connection.
|
IMilterStatus |
data(Properties properties)
Handle the DATA command.
|
IMilterStatus |
envfrom(byte[][] argv,
Properties properties)
Handle the envelope FROM command.
|
IMilterStatus |
envrcpt(byte[][] argv,
Properties properties)
Handle the envelope RCPT command.
|
IMilterStatus |
eoh(IMilterActions eohActions,
Properties properties)
End of a headers.
|
IMilterStatus |
eom(IMilterActions eomActions,
Properties properties)
End of a message.
|
int |
getActionFlags()
Get the Milter Action flags as to what this milter uses.
|
Map<Integer,Set<String>> |
getMacros()
Get desired macros during negotiation.
|
int |
getProtocolFlags()
Get the list of calls the MTA should not await replies for.
|
IMilterStatus |
header(byte[] name,
byte[] value)
Handle a message header.
|
IMilterStatus |
helo(String helohost,
Properties properties)
Handle the HELO/EHLO command.
|
int |
negotiateVersion(int mtaVersion,
int actionFlags,
int protocolFlags)
Prepares for protocol version negotiation.
|
void |
reset()
Called when receiving a
MilterConstants.SMFIC_QUIT_NC command from the MTA. |
IMilterStatus |
unknown(byte[] command,
Properties properties)
Handle an unknown SMTP command.
|
IMilterStatus connect(String hostname, InetAddress hostaddr, Properties properties)
hostname
- The host name of the message sender, as determined by a reverse lookup on the host address.hostaddr
- The host address, as determined by a getpeername()
call on the SMTP socket.properties
- Any properties (macros) received from the MTA.SMFIS_
return codes from IMilterStatus
. NOTE: The MTA will currently ignore
any custom values (values other than SMFIS_
values). Specifically, values created with
CustomMilterStatus.CustomMilterStatus(java.lang.String, java.lang.String, java.lang.String[])
will not be honored.IMilterStatus helo(String helohost, Properties properties)
helohost
- Value passed to HELO/EHLO command, which should be the domain name of the sending host (but is,
in practice, anything the sending host wants to send).properties
- Any properties (macros) received from the MTA.SMFIS_
return codes from IMilterStatus
.IMilterStatus envfrom(byte[][] argv, Properties properties)
envrcpt
.argv
- An array of SMTP command arguments. argv[0]
is guaranteed to be the sender address.
Later arguments are the ESMTP arguments. While the default encoding should be presumed to be ASCII, the value
decoding is left to the user. Often simply the default String.String(byte[])
constructor is enough.properties
- Any properties (macros) received from the MTA.SMFIS_
return codes from IMilterStatus
.IMilterStatus envrcpt(byte[][] argv, Properties properties)
envfrom(byte[][], java.util.Properties)
.argv
- An array of SMTP command arguments. argv[0]
is guaranteed to be the recipient address.
Later arguments are the ESMTP arguments. While the default encoding should be presumed to be ASCII, the value
decoding is left to the user. Often simply the default String.String(byte[])
constructor is enough.properties
- Any properties (macros) received from the MTA.SMFIS_
return codes from IMilterStatus
.IMilterStatus header(byte[] name, byte[] value)
envrcpt(byte[][], java.util.Properties)
and eoh(com.sendmail.milter.IMilterActions, java.util.Properties)
, once per message
header.name
- Header field name.value
- Header field value. The content of the header may include folded white space (i.e. multiple lines
with following white space). The trailing line terminator (CR/LF) is removed.
While the default encoding should be presumed to be ASCII, the value decoding is left to the user. Often simply
the default String.String(byte[])
constructor is enough. String.String(byte[])
constructor is
enough.
SMFIS_
return codes from IMilterStatus
.IMilterStatus eoh(IMilterActions eohActions, Properties properties)
header(byte[], byte[])
for a given message.eohActions
- Interface for effecting message changes.properties
- Any properties (macros) received from the MTA.SMFIS_
return codes from IMilterStatus
.IMilterStatus data(Properties properties)
eoh(com.sendmail.milter.IMilterActions, java.util.Properties)
and body(java.nio.ByteBuffer)
commands.properties
- Any properties (macros) received from the MTA.SMFIS_
return codes from IMilterStatus
.IMilterStatus body(ByteBuffer bodyp)
eoh(com.sendmail.milter.IMilterActions, java.util.Properties)
and eom(com.sendmail.milter.IMilterActions, java.util.Properties)
.bodyp
- This block of body data.SMFIS_
return codes from IMilterStatus
.IMilterStatus eom(IMilterActions eomActions, Properties properties)
body(java.nio.ByteBuffer)
for a given message.eomActions
- Interface for effecting message changes.properties
- Any properties (macros) received from the MTA.SMFIS_
return codes from IMilterStatus
.IMilterStatus abort()
eom(com.sendmail.milter.IMilterActions, java.util.Properties)
).SMFIS_
return codes from IMilterStatus
.IMilterStatus close()
SMFIS_
return codes from IMilterStatus
.IMilterStatus unknown(byte[] command, Properties properties)
command
- the incoming command.properties
- Any properties (macros) received from the MTA.SMFIS_
return codes from IMilterStatus
.int getActionFlags()
MilterConstants.SMFIF_ADDHDRS
,
MilterConstants.SMFIF_CHGBODY
, MilterConstants.SMFIF_ADDRCPT
,
MilterConstants.SMFIF_DELRCPT
, MilterConstants.SMFIF_CHGHDRS
,
MilterConstants.SMFIF_QUARANTINE
, MilterConstants.SMFIF_CHGFROM
,
MilterConstants.SMFIF_ADDRCPT_PAR
, MilterConstants.SMFIF_SETSYMLIST
constants.int getProtocolFlags()
MilterConstants.SMFIP_NOCONNECT
, MilterConstants.SMFIP_NOHELO
,
MilterConstants.SMFIP_NOMAIL
, MilterConstants.SMFIP_NORCPT
,
MilterConstants.SMFIP_NOBODY
, MilterConstants.SMFIP_NOHDRS
,
MilterConstants.SMFIP_NOEOH
, MilterConstants.SMFIP_NOUNKNOWN
,
MilterConstants.SMFIP_NODATA
, MilterConstants.SMFIP_SKIP
, MilterConstants.SMFIP_RCPT_REJ
,
MilterConstants.SMFIP_NR_HDR
, MilterConstants.SMFIP_NR_CONN
,
MilterConstants.SMFIP_NR_HELO
, MilterConstants.SMFIP_NR_MAIL
,
MilterConstants.SMFIP_NR_RCPT
, MilterConstants.SMFIP_NR_DATA
,
MilterConstants.SMFIP_NR_UNKN
, MilterConstants.SMFIP_NR_EOH
,
MilterConstants.SMFIP_NR_BODY
, MilterConstants.SMFIP_HDR_LEADSPC
or 0.int negotiateVersion(int mtaVersion, int actionFlags, int protocolFlags)
getActionFlags()
, getProtocolFlags()
and
getMacros()
are subsequently called and verified.
If getActionFlags()
requires flags not supported by the MTA, the negotiation will fail and the
connection will be terminated with a IMilterStatus.SMFIS_TEMPFAIL
response.
If getProtocolFlags()
requires flags not supported by the MTA, other than SMFIP_NR_
flags,
the negotiation will fail and the connection will be terminated with a IMilterStatus.SMFIS_TEMPFAIL
response.
If getProtocolFlags()
requires SMFIP_NR_ flags not supported by the MTA, the Milter server will emulate
them by sending IMilterStatus.SMFIS_CONTINUE
responses.
Normally your filter's flags should be constant, but here we give you a chance to turn some features off or do workarounds. Note that your implemented handler functions are always called if a packet arrives for them, even if you report that you don't use them. Sendmail accepts the results and complains in the logs that your filter is a liar.
mtaVersion
- Milter Protocol version of the Mail Transport Agent.actionFlags
- Actions flags for actions supported by the MTA. Prefixed with SMFIF_ in
MilterConstants
.protocolFlags
- Protocol flags supported by the MTA. Prefixed with SMFIP_ in MilterConstants
.void reset()
MilterConstants.SMFIC_QUIT_NC
command from the MTA. A stateful Milter must reset
itself to the same state it was in before the connect(java.lang.String, java.net.InetAddress, java.util.Properties)
call, or after the calls to
negotiateVersion(int, int, int)
, getActionFlags()
, getProtocolFlags()
and
getMacros()
, because it will be reused.Map<Integer,Set<String>> getMacros()
The macros themselves are available scattered with no particular grouping or order, with little to no description in the Sendmail documentation and some of them, but with proper description in the Postfix Milter documents.
MilterConstants.Macros
.Copyright © 2016. All rights reserved.