Milter.Milter Class Reference

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

Inheritance diagram for Milter.Milter:

## Public Member Functions

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

## Additional Inherited Members

Public Attributes inherited from Milter.Base
| header_bytes
Protected Member Functions inherited from Milter.Base
| _setctx (self, ctx)
| Attach this Milter to the low level milter.milterContext object.
Protected Attributes inherited from Milter.Base
| _ctx
| The low level milter.milterContext object.
| _actions
| A bitmask of actions this connection has negotiated to use.
| _protocol
| A bitmask of protocol options this connection has negotiated.

## 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()

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().

## close()

Milter.Milter.close | ( |  | self | ) |

Called when the connection is closed.

Reimplemented from Milter.Base.

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

Referenced by Milter.test.TestBase.connect(), and Milter.test.TestBase.feedFile().

## connect()

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

  hostname | the PTR name or bracketed IP of the SMTP client
  family | `socket.AF_INET`, `socket.AF_INET6`, or `socket.AF_UNIX`
  hostaddr | a 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()

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()

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().

## eoh()

Milter.Milter.eoh | ( |  | self | ) |

Called at the blank line that terminates the header fields.

Reimplemented from Milter.Base.

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

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

## eom()

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()

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

Called for each header field in the message body.

Parameters

  field | name decoded as ascii
  value | field 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()

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().

## log()

Milter.Milter.log | ( |  | self,
|  | * | msg
| ) |  |

Provide simple logging to sys.stdout.

Reimplemented from Milter.Base.

Referenced by Milter.Milter.abort(), Milter.Milter.close(), Milter.Milter.connect(), Milter.Milter.envfrom(), Milter.Milter.envrcpt(), Milter.Milter.eoh(), Milter.Milter.eom(), Milter.Milter.header(), Milter.Milter.hello(), and Milter.test.TestBase.setsymval().

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

- Milter/__init__.py