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
b3d63281
Commit
b3d63281
authored
14 years ago
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
Fix template so it actually runs - makes a better example that way :-)
parent
2133942c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
milter-template.py
+10
-7
10 additions, 7 deletions
milter-template.py
with
10 additions
and
7 deletions
milter-template.py
+
10
−
7
View file @
b3d63281
...
@@ -11,8 +11,9 @@ import Milter
...
@@ -11,8 +11,9 @@ import Milter
import
StringIO
import
StringIO
import
time
import
time
import
email
import
email
import
sys
from
socket
import
AF_INET
,
AF_INET6
from
socket
import
AF_INET
,
AF_INET6
from
Milter
import
parse_addr
from
Milter
.utils
import
parse_addr
class
myMilter
(
Milter
.
Base
):
class
myMilter
(
Milter
.
Base
):
...
@@ -23,7 +24,7 @@ class myMilter(Milter.Base):
...
@@ -23,7 +24,7 @@ class myMilter(Milter.Base):
# each connection runs in its own thread and has its own myMilter
# each connection runs in its own thread and has its own myMilter
# instance. Python code must be thread safe. This is trivial if only stuff
# instance. Python code must be thread safe. This is trivial if only stuff
# in myMilter instances is referenced.
# in myMilter instances is referenced.
@noreply
@
Milter.
noreply
def
connect
(
self
,
IPname
,
family
,
hostaddr
):
def
connect
(
self
,
IPname
,
family
,
hostaddr
):
# (self, 'ip068.subnet71.example.com', AF_INET, ('215.183.71.68', 4720) )
# (self, 'ip068.subnet71.example.com', AF_INET, ('215.183.71.68', 4720) )
# (self, 'ip6.mxout.example.com', AF_INET6,
# (self, 'ip6.mxout.example.com', AF_INET6,
...
@@ -71,7 +72,7 @@ class myMilter(Milter.Base):
...
@@ -71,7 +72,7 @@ class myMilter(Milter.Base):
## def envrcpt(self, to, *str):
## def envrcpt(self, to, *str):
@noreply
@
Milter.
noreply
def
envrcpt
(
self
,
recipient
,
*
str
):
def
envrcpt
(
self
,
recipient
,
*
str
):
rcptinfo
=
to
,
Milter
.
dictfromlist
(
str
)
rcptinfo
=
to
,
Milter
.
dictfromlist
(
str
)
self
.
R
.
append
(
rcptinfo
)
self
.
R
.
append
(
rcptinfo
)
...
@@ -79,17 +80,17 @@ class myMilter(Milter.Base):
...
@@ -79,17 +80,17 @@ class myMilter(Milter.Base):
return
Milter
.
CONTINUE
return
Milter
.
CONTINUE
@noreply
@
Milter.
noreply
def
header
(
self
,
name
,
hval
):
def
header
(
self
,
name
,
hval
):
self
.
fp
.
write
(
"
%s: %s
\n
"
%
(
name
,
hval
))
# add header to buffer
self
.
fp
.
write
(
"
%s: %s
\n
"
%
(
name
,
hval
))
# add header to buffer
return
Milter
.
CONTINUE
return
Milter
.
CONTINUE
@noreply
@
Milter.
noreply
def
eoh
(
self
):
def
eoh
(
self
):
self
.
fp
.
write
(
"
\n
"
)
# terminate headers
self
.
fp
.
write
(
"
\n
"
)
# terminate headers
return
Milter
.
CONTINUE
return
Milter
.
CONTINUE
@noreply
@
Milter.
noreply
def
body
(
self
,
chunk
):
def
body
(
self
,
chunk
):
self
.
fp
.
write
(
chunk
)
self
.
fp
.
write
(
chunk
)
return
Milter
.
CONTINUE
return
Milter
.
CONTINUE
...
@@ -125,6 +126,8 @@ class myMilter(Milter.Base):
...
@@ -125,6 +126,8 @@ class myMilter(Milter.Base):
## ===
## ===
def
main
():
def
main
():
socketname
=
"
/tmp/pythonsock
"
timeout
=
600
# Register to have the Milter factory create instances of your class:
# Register to have the Milter factory create instances of your class:
Milter
.
factory
=
myMilter
Milter
.
factory
=
myMilter
flags
=
Milter
.
CHGBODY
+
Milter
.
CHGHDRS
+
Milter
.
ADDHDRS
flags
=
Milter
.
CHGBODY
+
Milter
.
CHGHDRS
+
Milter
.
ADDHDRS
...
@@ -133,7 +136,7 @@ def main():
...
@@ -133,7 +136,7 @@ def main():
Milter
.
set_flags
(
flags
)
# tell Sendmail which features we use
Milter
.
set_flags
(
flags
)
# tell Sendmail which features we use
print
"
%s milter startup
"
%
time
.
strftime
(
'
%Y%b%d %H:%M:%S
'
)
print
"
%s milter startup
"
%
time
.
strftime
(
'
%Y%b%d %H:%M:%S
'
)
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
Milter
.
runmilter
(
"
pythonfilter
"
,
socketname
,
timeout
)
Milter
.
runmilter
(
"
test
"
,
socketname
,
timeout
)
print
"
%s bms milter shutdown
"
%
time
.
strftime
(
'
%Y%b%d %H:%M:%S
'
)
print
"
%s bms milter shutdown
"
%
time
.
strftime
(
'
%Y%b%d %H:%M:%S
'
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
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