Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymilter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
misc
pymilter
Commits
26605406
Commit
26605406
authored
10 years ago
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
Copy sendmail-devel libmilter api into documention, since milter.org is gone.
parent
161b4c31
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
Milter/__init__.py
+14
-14
14 additions, 14 deletions
Milter/__init__.py
doc/mainpage.py
+3
-3
3 additions, 3 deletions
doc/mainpage.py
doc/milter.py
+20
-20
20 additions, 20 deletions
doc/milter.py
makefile
+2
-1
2 additions, 1 deletion
makefile
milter-template.py
+1
-1
1 addition, 1 deletion
milter-template.py
with
40 additions
and
39 deletions
Milter/__init__.py
+
14
−
14
View file @
26605406
...
...
@@ -257,7 +257,7 @@ class Base(object):
## Defined by subclasses to write log messages.
def
log
(
self
,
*
msg
):
pass
## Called for each connection to the MTA. Called by the
# <a href="
https://www.milter.org/developers/
api/xxfi_connect">
# <a href="
milter_
api/xxfi_connect
.html
">
# xxfi_connect</a> callback.
# The <code>hostname</code> 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.
...
...
@@ -294,7 +294,7 @@ class Base(object):
@nocallback
def
hello
(
self
,
hostname
):
return
CONTINUE
## Called when the SMTP client says MAIL FROM. Called by the
# <a href="
https://www.milter.org/developers/
api/xxfi_envfrom">
# <a href="
milter_
api/xxfi_envfrom
.html
">
# xxfi_envfrom</a> callback.
# Returning REJECT rejects the message, but not the connection.
# The sender is the "envelope" from as defined by
...
...
@@ -305,7 +305,7 @@ class Base(object):
@nocallback
def
envfrom
(
self
,
f
,
*
str
):
return
CONTINUE
## Called when the SMTP client says RCPT TO. Called by the
# <a href="
https://www.milter.org/developers/
api/xxfi_envrcpt">
# <a href="
milter_
api/xxfi_envrcpt
.html
">
# xxfi_envrcpt</a> callback.
# Returning REJECT rejects the current recipient, not the entire message.
# The recipient is the "envelope" recipient as defined by
...
...
@@ -371,7 +371,7 @@ class Base(object):
return
p
## Negotiate milter protocol options. Called by the
# <a href="
https://www.milter.org/developers/
api/xxfi_negotiate">
# <a href="
milter_
api/xxfi_negotiate
.html
">
# xffi_negotiate</a> callback. This is an advanced callback,
# do not override unless you know what you are doing. Most
# negotiation can be done simply by using the supplied
...
...
@@ -402,7 +402,7 @@ class Base(object):
## Return the value of an MTA macro. Sendmail macro names
# are either single chars (e.g. "j") or multiple chars enclosed
# in braces (e.g. "{auth_type}"). Macro names are MTA dependent.
# See <a href="
https://www.milter.org/developers/
api/smfi_getsymval">
# See <a href="
milter_
api/smfi_getsymval
.html
">
# smfi_getsymval</a> for default sendmail macros.
# @param sym the macro name
def
getsymval
(
self
,
sym
):
...
...
@@ -416,7 +416,7 @@ class Base(object):
# head scratching. What will <i>really</i> irritate you, however,
# is that if you carefully double any '%%', your message will be
# sent - but with the '%%' still doubled!
# See <a href="
https://www.milter.org/developers/
api/smfi_setreply">
# See <a href="
milter_
api/smfi_setreply
.html
">
# smfi_setreply</a> for more information.
# @param rcode The three-digit (RFC 821/2821) SMTP reply code as a string.
# rcode cannot be None, and <b>must be a valid 4XX or 5XX reply code</b>.
...
...
@@ -459,7 +459,7 @@ class Base(object):
# Milter methods which can only be called from eom callback.
## Add a mail header field.
# Calls <a href="
https://www.milter.org/developers/
api/smfi_addheader">
# Calls <a href="
milter_
api/smfi_addheader
.html
">
# smfi_addheader</a>.
# The <code>Milter.ADDHDRS</code> action flag must be set.
#
...
...
@@ -473,7 +473,7 @@ class Base(object):
return
self
.
_ctx
.
addheader
(
field
,
value
,
idx
)
## Change the value of a mail header field.
# Calls <a href="
https://www.milter.org/developers/
api/smfi_chgheader">
# Calls <a href="
milter_
api/smfi_chgheader
.html
">
# smfi_chgheader</a>.
# The <code>Milter.CHGHDRS</code> action flag must be set.
#
...
...
@@ -487,7 +487,7 @@ class Base(object):
return
self
.
_ctx
.
chgheader
(
field
,
idx
,
value
)
## Add a recipient to the message.
# Calls <a href="
https://www.milter.org/developers/
api/smfi_addrcpt">
# Calls <a href="
milter_
api/smfi_addrcpt
.html
">
# smfi_addrcpt</a>.
# If no corresponding mail header is added, this is like a Bcc.
# The syntax of the recipient is the same as used in the SMTP
...
...
@@ -507,7 +507,7 @@ class Base(object):
raise
DisabledAction
(
"
ADDRCPT_PAR
"
)
return
self
.
_ctx
.
addrcpt
(
rcpt
,
params
)
## Delete a recipient from the message.
# Calls <a href="
https://www.milter.org/developers/
api/smfi_delrcpt">
# Calls <a href="
milter_
api/smfi_delrcpt
.html
">
# smfi_delrcpt</a>.
# The recipient should match one passed to the envrcpt callback.
# The <code>Milter.DELRCPT</code> action flag must be set.
...
...
@@ -520,7 +520,7 @@ class Base(object):
return
self
.
_ctx
.
delrcpt
(
rcpt
)
## Replace the message body.
# Calls <a href="
https://www.milter.org/developers/
api/smfi_replacebody">
# Calls <a href="
milter_
api/smfi_replacebody
.html
">
# smfi_replacebody</a>.
# The entire message body must be replaced.
# Call repeatedly with blocks of data until the entire body is transferred.
...
...
@@ -534,7 +534,7 @@ class Base(object):
return
self
.
_ctx
.
replacebody
(
body
)
## Change the SMTP envelope sender address.
# Calls <a href="
https://www.milter.org/developers/
api/smfi_chgfrom">
# Calls <a href="
milter_
api/smfi_chgfrom
.html
">
# smfi_chgfrom</a>.
# The syntax of the sender is that same as used in the SMTP
# MAIL FROM command (and as delivered to the envfrom callback),
...
...
@@ -551,7 +551,7 @@ class Base(object):
return
self
.
_ctx
.
chgfrom
(
sender
,
params
)
## Quarantine the message.
# Calls <a href="
https://www.milter.org/developers/
api/smfi_quarantine">
# Calls <a href="
milter_
api/smfi_quarantine
.html
">
# smfi_quarantine</a>.
# When quarantined, a message goes into the mailq as if to be delivered,
# but delivery is deferred until the message is unquarantined.
...
...
@@ -565,7 +565,7 @@ class Base(object):
return
self
.
_ctx
.
quarantine
(
reason
)
## Tell the MTA to wait a bit longer.
# Calls <a href="
https://www.milter.org/developers/
api/smfi_progress">
# Calls <a href="
milter_
api/smfi_progress
.html
">
# smfi_progress</a>.
# Resets timeouts in the MTA that detect a "hung" milter.
def
progress
(
self
):
...
...
This diff is collapsed.
Click to expand it.
doc/mainpage.py
+
3
−
3
View file @
26605406
## @mainpage Writing Milters in Python
#
# At the lowest level, the <code>milter</code> module provides a thin wrapper
# around the <a href="
https://www.milter.org/developers/
api/index"> sendmail
# around the <a href="
milter_
api/index
.html
"> sendmail
# libmilter API</a>. This API lets you register callbacks for a number of
# events in the process of sendmail receiving a message via SMTP. These
# events include the initial connection from a MTA, the envelope sender and
...
...
@@ -39,10 +39,10 @@
# @section threading
#
# The libmilter library which pymilter wraps
# <a href="
https://www.milter.org/developers/
overview#SignalHandling">handles
# <a href="
milter_
overview#SignalHandling">handles
# all signals</a> itself, and expects to be called from a single main thread.
# It handles SIGTERM, SIGHUP, and SIGINT, mapping the first two to
# <a href="
https://www.milter.org/developers/
api/smfi_stop">smfi_stop</a>
# <a href="
milter_
api/smfi_stop
.html
">smfi_stop</a>
# and the last to an internal ABORT.
#
# If you use python threads or threading modules, then signal handling gets
...
...
This diff is collapsed.
Click to expand it.
doc/milter.py
+
20
−
20
View file @
26605406
...
...
@@ -75,44 +75,44 @@ NOREPLY = 6
# and converts function callbacks to instance method invocations.
#
class
milterContext
(
object
):
## Calls <a href="
https://www.milter.org/developers/
api/smfi_getsymval">smfi_getsymval</a>.
## Calls <a href="
milter_
api/smfi_getsymval
.html
">smfi_getsymval</a>.
def
getsymval
(
self
,
sym
):
pass
## Calls <a href="
https://www.milter.org/developers/
api/smfi_setreply">
## Calls <a href="
milter_
api/smfi_setreply
.html
">
# smfi_setreply</a> or
# <a href="
https://www.milter.org/developers/
api/smfi_setmlreply">
# <a href="
milter_
api/smfi_setmlreply
.html
">
# smfi_setmlreply</a>.
# @param rcode SMTP response code
# @param xcode extended SMTP response code
# @param msg one or more message lines. If the MTA does not support
# multiline messages, only the first is used.
def
setreply
(
self
,
rcode
,
xcode
,
*
msg
):
pass
## Calls <a href="
https://www.milter.org/developers/
api/smfi_addheader">smfi_addheader</a>.
## Calls <a href="
milter_
api/smfi_addheader
.html
">smfi_addheader</a>.
def
addheader
(
self
,
name
,
value
,
idx
=-
1
):
pass
## Calls <a href="
https://www.milter.org/developers/
api/smfi_chgheader">smfi_chgheader</a>.
## Calls <a href="
milter_
api/smfi_chgheader
.html
">smfi_chgheader</a>.
def
chgheader
(
self
,
name
,
idx
,
value
):
pass
## Calls <a href="
https://www.milter.org/developers/
api/smfi_addrcpt">smfi_addrcpt</a>.
## Calls <a href="
milter_
api/smfi_addrcpt
.html
">smfi_addrcpt</a>.
def
addrcpt
(
self
,
rcpt
,
params
=
None
):
pass
## Calls <a href="
https://www.milter.org/developers/
api/smfi_delrcpt">smfi_delrcpt</a>.
## Calls <a href="
milter_
api/smfi_delrcpt
.html
">smfi_delrcpt</a>.
def
delrcpt
(
self
,
rcpt
):
pass
## Calls <a href="
https://www.milter.org/developers/
api/smfi_replacebody">smfi_replacebody</a>.
## Calls <a href="
milter_
api/smfi_replacebody
.html
">smfi_replacebody</a>.
def
replacebody
(
self
,
data
):
pass
## Attach a Python object to this connection context.
# @return the old value or None
def
setpriv
(
self
,
priv
):
pass
## Return the Python object attached to this connection context.
def
getpriv
(
self
):
pass
## Calls <a href="
https://www.milter.org/developers/
api/smfi_quarantine">smfi_quarantine</a>.
## Calls <a href="
milter_
api/smfi_quarantine
.html
">smfi_quarantine</a>.
def
quarantine
(
self
,
reason
):
pass
## Calls <a href="
https://www.milter.org/developers/
api/smfi_progress">smfi_progress</a>.
## Calls <a href="
milter_
api/smfi_progress
.html
">smfi_progress</a>.
def
progress
(
self
):
pass
## Calls <a href="
https://www.milter.org/developers/
api/smfi_chgfrom">smfi_chgfrom</a>.
## Calls <a href="
milter_
api/smfi_chgfrom
.html
">smfi_chgfrom</a>.
def
chgfrom
(
self
,
sender
,
param
=
None
):
pass
## Tell the MTA which macro values we are interested in for a given stage.
# Of interest only when you need to squeeze a few more bytes of bandwidth.
# It may only be called from the negotiate callback.
# The protocol stages are
# M_CONNECT, M_HELO, M_ENVFROM, M_ENVRCPT, M_DATA, M_EOM, M_EOH.
# Calls <a href="
https://www.milter.org/developers/
api/smfi_setsymlist">smfi_setsymlist</a>.
# Calls <a href="
milter_
api/smfi_setsymlist
.html
">smfi_setsymlist</a>.
# @param stage protocol stage in which the macro list should be used
# @param macrolist a space separated list of macro names
def
setsymlist
(
self
,
stage
,
macrolist
):
pass
...
...
@@ -160,15 +160,15 @@ def set_exception_policy(code): pass
# member functions are actually overridden by an application class.
# @param name the %milter name by which the MTA finds us
# @param negotiate the
# <a href="
https://www.milter.org/developers/
api/xxfi_negotiate">
# <a href="
milter_
api/xxfi_negotiate
.html
">
# xxfi_negotiate</a> callback, called to negotiate supported
# actions, callbacks, and protocol steps.
# @param unknown the
# <a href="
https://www.milter.org/developers/
api/xxfi_unknown">
# <a href="
milter_
api/xxfi_unknown
.html
">
# xxfi_unknown</a> callback, called when for SMTP commands
# not recognized by the MTA. (Extend SMTP in your milter!)
# @param data the
# <a href="
https://www.milter.org/developers/
api/xxfi_data">
# <a href="
milter_
api/xxfi_data
.html
">
# xxfi_data</a> callback, called when the DATA
# SMTP command is received.
def
register
(
name
,
negotiate
=
None
,
unknown
=
None
,
data
=
None
):
pass
...
...
@@ -178,19 +178,19 @@ def register(name,negotiate=None,unknown=None,data=None): pass
# call to milter.setconn() which will be the interface between MTAs and the
# %milter. This allows the calling application to ensure that the socket can be
# created. If this is not called, milter.main() will do so implicitly.
# Calls <a href="
https://www.milter.org/developers/
api/smfi_opensocket">
# Calls <a href="
milter_
api/smfi_opensocket
.html
">
# smfi_opensocket</a>. While not documented for libmilter, my experiments
# indicate that you must call register() before calling opensocket().
# @param rmsock Try to remove an existing unix domain socket if true.
def
opensocket
(
rmsock
):
pass
## Transfer control to libmilter.
# Calls <a href="
https://www.milter.org/developers/
api/smfi_main">
# Calls <a href="
milter_
api/smfi_main
.html
">
# smfi_main</a>.
def
main
():
pass
## Set the libmilter debugging level.
# <a href="
https://www.milter.org/developers/
api/smfi_setdbg">smfi_setdbg</a>
# <a href="
milter_
api/smfi_setdbg
.html
">smfi_setdbg</a>
# sets the %milter library's internal debugging level to a new level
# so that code details may be traced. A level of zero turns off debugging. The
# greater (more positive) the level the more detailed the debugging. Six is the
...
...
@@ -198,12 +198,12 @@ def main(): pass
def
setdbg
(
lev
):
pass
## Set timeout for MTA communication.
# Calls <a href="
https://www.milter.org/developers/
api/smfi_settimeout">
# Calls <a href="
milter_
api/smfi_settimeout
.html
">
# smfi_settimeout</a>. Must be called before calling main().
def
settimeout
(
secs
):
pass
## Set socket backlog.
# Calls <a href="
https://www.milter.org/developers/
api/smfi_setbacklog">
# Calls <a href="
milter_
api/smfi_setbacklog
.html
">
# smfi_setbacklog</a>. Must be called before calling main().
def
setbacklog
(
n
):
pass
...
...
This diff is collapsed.
Click to expand it.
makefile
+
2
−
1
View file @
26605406
web
:
doxygen
test
-L
doc/html/milter_api
||
ln
-sf
/usr/share/doc/sendmail-devel-
*
doc/html/milter_api
rsync
-ravKk
doc/html/ spidey2.bmsi.com:/Public/pymilter
cd
doc/html
;
zip
-r
../../doc .
rsync
-ravK
doc/html/ spidey2.bmsi.com:/Public/pymilter
VERSION
=
1.0
CVSTAG
=
pymilter-1_0
...
...
This diff is collapsed.
Click to expand it.
milter-template.py
+
1
−
1
View file @
26605406
## To roll your own milter, create a class that extends Milter.
# See the pymilter project at http://bmsi.com/python/milter.html
# based on Sendmail's milter API
http://www.milter.org/milter_api/api.html
# based on Sendmail's milter API
# This code is open-source on the same terms as Python.
## Milter calls methods of your class at milter events.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment