pymilter  1.0.5
Public Member Functions | List of all members
Milter.Milter Class Reference

A logging but otherwise do nothing Milter base class. More...

Inheritance diagram for Milter.Milter:
Milter.Base

Public Member Functions

def log (self, *msg)
 Provide simple logging to sys.stdout.
 
def connect (self, hostname, family, hostaddr)
 Called for each connection to the MTA. More...
 
def hello (self, hostname)
 Called when the SMTP client says HELO. More...
 
def envfrom (self, f, *str)
 
def envrcpt (self, to, *str)
 Called when the SMTP client says RCPT TO. More...
 
def header (self, field, value)
 Called for each header field in the message body. More...
 
def eoh (self)
 Called at the blank line that terminates the header fields.
 
def eom (self)
 Called at the end of the message body. More...
 
def abort (self)
 Called when the connection is abnormally terminated. More...
 
def close (self)
 Called when the connection is closed.
 
- Public Member Functions inherited from Milter.Base
def envfrom_bytes (self, *b)
 Called with bytes by default global envfrom callback. More...
 
def envrcpt_bytes (self, *b)
 Called with bytes by default global envrcpt callback. More...
 
def data (self)
 Called when the SMTP client says DATA. More...
 
def header_bytes (self, fld, val)
 Called with bytes by default global header callback. More...
 
def body (self, blk)
 Called to supply the body of the message to the Milter by chunks. More...
 
def unknown (self, cmd)
 Called when the SMTP client issues an unknown command. More...
 
def protocol_mask (klass)
 Return mask of SMFIP_N* protocol option bits to clear for this class The @nocallback and @noreply decorators set the milter_protocol function attribute to the protocol mask bit to pass to libmilter, causing that callback or its reply to be skipped. More...
 
def negotiate (self, opts)
 Negotiate milter protocol options. More...
 
def getsymval (self, sym)
 Return the value of an MTA macro. More...
 
def setreply (self, rcode, xcode=None, msg=None, *ml)
 Set the SMTP reply code and message. More...
 
def setsymlist (self, stage, *macros)
 Tell the MTA which macro names will be used. More...
 
def addheader (self, field, value, idx=-1)
 Add a mail header field. More...
 
def chgheader (self, field, idx, value)
 Change the value of a mail header field. More...
 
def addrcpt (self, rcpt, params=None)
 Add a recipient to the message. More...
 
def delrcpt (self, rcpt)
 Delete a recipient from the message. More...
 
def replacebody (self, body)
 Replace the message body. More...
 
def chgfrom (self, sender, params=None)
 Change the SMTP envelope sender address. More...
 
def quarantine (self, reason)
 Quarantine the message. More...
 
def progress (self)
 Tell the MTA to wait a bit longer. More...
 

Additional Inherited Members

- Public Attributes inherited from Milter.Base
 header_bytes
 

Detailed Description

A logging but otherwise do nothing Milter base class.

This is included for compatibility with previous versions of pymilter. The logging callbacks are marked @noreply.

Member Function Documentation

◆ abort()

def Milter.Milter.abort (   self)

Called when the connection is abnormally terminated.

The close callback is still called also.

Reimplemented from Milter.Base.

References Milter.Base.log(), Milter.Milter.log(), and Milter.test.TestBase.log().

◆ connect()

def Milter.Milter.connect (   self,
  hostname,
  family,
  hostaddr 
)

Called for each connection to the MTA.

Called by the xxfi_connect callback.
The hostname provided by the local MTA is either the PTR name or the IP in the form "[1.2.3.4]" if no PTR is available. The format of hostaddr depends on the socket family:

socket.AF_INET
A tuple of (IP as string in dotted quad form, integer port)
socket.AF_INET6
A tuple of (IP as a string in standard representation, integer port, integer flow info, integer scope id)
socket.AF_UNIX
A string with the socketname

To vary behavior based on what port the client connected to, for example skipping blacklist checks for port 587 (which must be authenticated), use getsymval('{daemon_port}') . The {daemon_port} macro must be enabled in sendmail.cf

 O Milter.macros.connect=j, _, {daemon_name}, {daemon_port}, {if_name}, {if_addr}
 

or sendmail.mc

 define(`confMILTER_MACROS_CONNECT', ``j, _, {daemon_name}, {daemon_port}, {if_name}, {if_addr}'')dnl
 
Parameters
hostnamethe PTR name or bracketed IP of the SMTP client
familysocket.AF_INET, socket.AF_INET6, or socket.AF_UNIX
hostaddra tuple or string with peer IP or socketname

Reimplemented from Milter.Base.

References Milter.Base.log(), Milter.Milter.log(), and Milter.test.TestBase.log().

◆ envfrom()

def Milter.Milter.envfrom (   self,
  f,
str 
)
Called to begin each message.
f -> string             message sender
str -> tuple    additional ESMTP parameters

Reimplemented from Milter.Base.

References Milter.Base.log(), Milter.Milter.log(), and Milter.test.TestBase.log().

Referenced by Milter.Base.envfrom_bytes(), and Milter.test.TestBase.feedFile().

◆ envrcpt()

def Milter.Milter.envrcpt (   self,
  to,
str 
)

Called when the SMTP client says RCPT TO.

Called by the xxfi_envrcpt callback. Returning REJECT rejects the current recipient, not the entire message. The recipient is the "envelope" recipient as defined by RFC 5321. For recipients defined in RFC 5322, for example To: or Cc:, see the header callback .

Reimplemented from Milter.Base.

References Milter.Base.log(), Milter.Milter.log(), and Milter.test.TestBase.log().

Referenced by Milter.Base.envrcpt_bytes(), and Milter.test.TestBase.feedFile().

◆ eom()

def Milter.Milter.eom (   self)

Called at the end of the message body.

Most of the message manipulation actions can only take place from the eom callback.

Reimplemented from Milter.Base.

References Milter.Base.log(), Milter.Milter.log(), and Milter.test.TestBase.log().

Referenced by Milter.test.TestBase.feedFile().

◆ header()

def Milter.Milter.header (   self,
  field,
  value 
)

Called for each header field in the message body.

Parameters
fieldname decoded as ascii
valuefield value decoded as utf-8 on python3

Reimplemented from Milter.Base.

References Milter.Base.log(), Milter.Milter.log(), and Milter.test.TestBase.log().

Referenced by Milter.Base.header_bytes().

◆ hello()

def Milter.Milter.hello (   self,
  hostname 
)

Called when the SMTP client says HELO.

Returning REJECT prevents progress until a valid HELO is provided; this almost always results in terminating the connection.

Reimplemented from Milter.Base.

References Milter.Base.log(), Milter.Milter.log(), and Milter.test.TestBase.log().

Referenced by Milter.test.TestBase.connect().


The documentation for this class was generated from the following file: