Note: This document should be generated from source at some point. It also lacks the documentation of all attributes currently.
A PurePythonMilter app is instantiated by providing the hooks to configure and which flags to set.
Example:
mymilter = PurePythonMilter(
hook_on_connect=my_on_connect,
can_add_headers=True,
)Hooks point to a callable which need to have a return type annotation.
A hook callable must accept exactly one argument; one of the hook-specific Command classes listed in the section below.
A None return type annotation will hint the MTA that the hook will not generate any
response and it will continue, so in that case you must not return a response.
This applies as possible return type of all of the hooks below.
-
hook_on_connect(cmd: Connect)return type:
Noneor any (subclass) ofVerdictOrContinue -
hook_on_helo(cmd: Helo)return type:
Noneor any (subclass) ofVerdictOrContinue -
hook_on_mail_from(cmd: MailFrom)return type:
Noneor any (subclass) ofVerdictOrContinue -
hook_on_rcpt_to(cmd: RcptTo)return type:
Noneor any (subclass) ofVerdictOrContinue -
hook_on_data(cmd: Data)return type:
Noneor any (subclass) ofVerdictOrContinue -
hook_on_header(cmd: Header)return type:
Noneor any (subclass) ofVerdictOrContinue -
hook_on_end_of_headers(cmd: EndOfHeaders)return type:
Noneor any (subclass) ofVerdictOrContinue -
hook_on_body_chunk(cmd: BodyChunk)return type:
Noneor any (subclass) ofVerdictOrContinue,SkipToNextStage -
hook_on_end_of_message(cmd: EndOfMessage)return type:
Noneor any (subclass) ofAbstractResponse.Noneis translated intoContinue(). -
hook_on_abort(cmd: Abort)return type:
None -
hook_on_quit(cmd: Quit)return type:
None -
hook_on_unknown(cmd: Unknown)return type:
Noneor any (subclass) ofVerdictOrContinue
on_rcpt_to_include_rejected(default: False)headers_with_leading_space(default: False)
-
can_add_headers(default: False)in order to use
AppendHeaderorInsertHeadermanipulations. -
can_add_recipients(default: False)in order to use the
AddRecipientmanipulation. -
can_add_recipients_with_esmtp_args(default: False)in order to use the
AddRecipientWithEsmtpArgsmanipulation. -
can_change_body(default: False)in order to use the
ReplaceBodyChunkmanipulation. -
can_change_headers(default: False)in order to use the
ChangeHeadermanipulation. -
can_change_mail_from(default: False)in order to use the
ChangeMailFrommanipulation. -
can_remove_recipients(default: False)in order to use the
RemoveRecipientmanipulation. -
can_quarantine(default: False)in order to use the
Quarantineresponse inhook_on_end_of_message.
- BaseCommand
DataEndOfHeadersEndOfMessageAbortQuitQuitNoClose- BaseCommandWithData
OptionsNegotiateConnectHeloHeaderBodyChunkUnknownDefineMacro- BaseMailFromAndRcptTo
MailFromRcptTo
- AbstractBaseResponse
- AbstractManipulation
- BaseChangeRecipient
AddRecipientAddRecipientWithEsmtpArgsRemoveRecipient
- BaseHeaderManipulation
AppendHeaderInsertHeaderChangeHeader
ReplaceBodyChunkChangeMailFrom
- BaseChangeRecipient
- AbstractResponse
- AbstractVerdict
- BaseVerdictNoData
AcceptRejectDiscardMessageCauseConnectionFail
- BaseReplyWithCode
RejectWithCodeTempFailWithCode
Quarantine
- BaseVerdictNoData
- BaseResponseNoData
ContinueSkipToNextStageProgress
OptionsNegotiateResponse
- AbstractVerdict
- AbstractManipulation
VerdictOrContinue = AbstractVerdict | Continue