- Member Milter.dictfromlist (args)
- You probably want Milter.param2dict instead.
- Class Milter.test.TestBase
- Use Milter.test.TestCtx
def _feedMsg(self, fname, sender="spam@adv.com", *rcpts)
Feed an email contained in a file to the milter.
Definition: testctx.py:295
def abort(self)
Called when the connection is abnormally terminated.
Definition: __init__.py:372
_priv
Usually the Milter application derived from Milter.Base.
Definition: testctx.py:27
greylist_time
Definition: greylist.py:39
def setliteral(self, *args)
Definition: sgmllib.py:88
rawdata
Definition: sgmllib.py:74
def _setctx(self, ctx)
Attach this Milter to the low level milter.milterContext object.
Definition: __init__.py:242
def handle_special(self, data)
Definition: mime.py:446
def settimeout(secs)
Set timeout for MTA communication.
Definition: milter.py:203
def log(self, *msg)
Defined by subclasses to write log messages.
Definition: __init__.py:285
lasttag
Definition: sgmllib.py:76
_delrcpt
List of recipients deleted.
Definition: testctx.py:29
Enhance email.message.Message.
Definition: mime.py:175
def parse_starttag(self, i)
Definition: sgmllib.py:238
def get_payload(self, i=None, decode=False)
Definition: mime.py:279
def get(self, sect, opt)
Definition: config.py:14
def _eom(self)
Definition: testctx.py:242
def handle_endtag(self, tag, method)
Definition: sgmllib.py:384
_reply
Reply codes and messages set by the milter.
Definition: testctx.py:35
_body
The message body.
Definition: test.py:33
def getsymval(self, sym)
Calls smfi_getsymval.
Definition: milter.py:79
def envrcpt(self, to, *str)
Called when the SMTP client says RCPT TO.
Definition: __init__.py:644
def close(self)
Called when the connection is closed.
Definition: __init__.py:671
def unquote(s)
Definition: mime.py:146
_headerschanged
True if the milter changed any headers.
Definition: testctx.py:43
def _envrcpt(self, s)
Definition: testctx.py:205
greylist_time
Definition: greysql.py:19
def setsymlist(self, stage, *macros)
Tell the MTA which macro names will be used.
Definition: __init__.py:480
def uniqueID()
Definition: __init__.py:29
def addrcpt(self, rcpt, params=None)
Calls smfi_addrcpt.
Definition: milter.py:94
def feedFile(self, fp, sender="spam@adv.com", rcpt="victim@lamb.com", *rcpts)
Feed a file like object to the milter.
Definition: test.py:156
def __call__(self, msg, savname=None, check=check_ext, scan_rfc822=True, scan_zip=False)
Definition: mime.py:389
def data(self)
Called when the SMTP client says DATA.
Definition: __init__.py:350
def connect(self, hostname, family, hostaddr)
Called for each connection to the MTA.
Definition: __init__.py:623
firstseen
Definition: greylist.py:24
def abort(self)
Called when the connection is abnormally terminated.
Definition: __init__.py:666
def parse_header(val)
Decode headers gratuitously encoded to hide the content.
Definition: utils.py:204
def handle_data(self, data)
Definition: sgmllib.py:439
def set_abort_callback(cb)
Definition: milter.py:137
Test mixin for unit testing milter applications.
Definition: test.py:19
def convert_entityref(self, name)
Definition: sgmllib.py:418
submsg
Definition: mime.py:180
def set_close_callback(cb)
Definition: milter.py:138
def envcallback(c, args)
Definition: __init__.py:738
basename
Definition: plock.py:11
def header(self, field, value)
Called for each header field in the message body.
Definition: __init__.py:650
def feedMsg(self, fname, sender="spam@adv.com", *rcpts)
Feed an email contained in a file to the milter.
Definition: test.py:213
def finish_starttag(self, tag, attrs)
Definition: sgmllib.py:331
factory
The milter connection factory This factory method is called for each connection to create the python ...
Definition: __init__.py:684
lastseen
Definition: greylist.py:25
def noreply(func)
Function decorator to disable callback reply.
Definition: __init__.py:165
def symlist(*syms)
Function decorator to set macros used in a callback.
Definition: __init__.py:188
def header(self, field, value)
Called for each header field in the message body.
Definition: __init__.py:353
def progress(self)
Reset activity timer.
Definition: testctx.py:141
def stop()
Stop the milter gracefully.
Definition: milter.py:230
def delrcpt(self, rcpt)
Delete a recipient from the message.
Definition: __init__.py:554
def zipnames(txt)
Return a list of filenames in a zip file.
Definition: mime.py:122
def set_connect_callback(cb)
Definition: milter.py:130
lock
Definition: greylist.py:43
ignoring
Definition: mime.py:489
def getpriv(self)
Return the Python object attached to this connection context.
Definition: milter.py:103
def enable_protocols(klass, mask)
Class decorator to enable optional protocol steps.
Definition: __init__.py:93
scan_rfc822
Definition: mime.py:394
def negotiate_callback(ctx, opts)
Connect context to connection instance and return enabled callbacks.
Definition: __init__.py:688
def lock(self, lockname=None, mode=0o660, strict_perms=False)
Definition: plock.py:14
literal
Definition: sgmllib.py:78
def setdbg(lev)
Set the libmilter debugging level.
Definition: milter.py:198
modified
Definition: mime.py:181
age
Definition: cache.py:57
def setreply(self, rcode, xcode, *msg)
Save the reply codes and messages in self._reply.
Definition: test.py:120
testdata
Definition: sgmllib.py:464
def protocol_mask(klass)
Return mask of SMFIP_N* protocol option bits to clear for this class The @nocallback and @noreply dec...
Definition: __init__.py:387
def close(self)
Definition: sgmllib.py:511
def set_eoh_callback(cb)
Definition: milter.py:135
def addr2bin(s)
Definition: utils.py:33
def _abort(self)
Definition: testctx.py:144
def envfrom(self, f, *str)
Called when the SMTP client says MAIL FROM.
Definition: __init__.py:333
def chgfrom(self, sender, params=None)
Change the SMTP envelope sender address.
Definition: __init__.py:585
def runmilter(name, socketname, timeout=0, rmsock=True)
Run the milter.
Definition: __init__.py:757
def chgfrom(self, sender, param=None)
Calls smfi_chgfrom.
Definition: milter.py:109
def _close(self)
Definition: testctx.py:149
def set_body_callback(cb)
Definition: milter.py:136
scan_zip
Definition: mime.py:395
stack
Definition: sgmllib.py:75
def connect(self, hostname, family, hostaddr)
Called for each connection to the MTA.
Definition: __init__.py:317
Milter context for unit testing milter applications.
Definition: testctx.py:23
def dump(self, file, unixfrom=False)
Definition: mime.py:242
def goahead(self, end)
Definition: sgmllib.py:116
def DNSLookup(name, qtype)
Lookup DNS records by label and RR type.
Definition: dns.py:16
def create_msg(v, rcptlist=None, origmsg=None, template=None)
Definition: dsn.py:168
def getversion()
Retrieve the runtime libmilter version.
Definition: milter.py:244
def _envfrom(self, *s)
Definition: testctx.py:196
def reset(self)
Definition: sgmllib.py:71
A do "nothing" Milter base class representing an SMTP connection.
Definition: __init__.py:238
fp
Definition: plock.py:12
logfp
Definition: test.py:23
def log(self, *msg)
Definition: test.py:49
def rejected_recipients(klass)
Milter rejected recipients.
Definition: __init__.py:111
def dictfromlist(args)
Convert ESMTP parameters with values to a keyword dictionary.
Definition: __init__.py:717
def getdiag()
Retrieve diagnostic info.
Definition: milter.py:237
def negotiate(self, opts)
Negotiate milter protocol options.
Definition: __init__.py:415
def close_callback(ctx)
Disconnect milterContext and call close method.
Definition: __init__.py:706
_delrcpt
List of recipients deleted.
Definition: test.py:27
def handle_pi(self, data)
Definition: sgmllib.py:451
def chgheader(self, name, idx, value)
Calls smfi_chgheader.
Definition: milter.py:92
def set_header_callback(cb)
Definition: milter.py:134
def setreply(self, rcode, xcode, *msg)
Calls smfi_setreply or smfi_setmlreply.
Definition: milter.py:88
def flush(self)
Definition: sgmllib.py:472
def bin2long6(s)
Definition: utils.py:45
_addrcpt
List of recipients added.
Definition: testctx.py:31
def replacebody(self, body)
Replace the message body.
Definition: __init__.py:568
def setreply(self, rcode, xcode=None, msg=None, *ml)
Set the SMTP reply code and message.
Definition: __init__.py:460
_headerschanged
True if the milter changed any headers.
Definition: test.py:37
def unknown_charref(self, ref)
Definition: sgmllib.py:457
_protocol
A bitmask of protocol options this connection has negotiated.
Definition: __init__.py:280
Definition: greylist.py:19
_activity
Last activity.
Definition: testctx.py:55
def convert_codepoint(self, codepoint)
Definition: sgmllib.py:403
def parse_endtag(self, i)
Definition: sgmllib.py:311
def decode(s, convert_eols=None)
Fix email.base64mime.decode to add any missing padding.
Definition: utils.py:161
def handle_entityref(self, name)
Definition: sgmllib.py:430
_symlist
The macros returned by protocol stage.
Definition: testctx.py:37
_reply
Reply codes and messages set by the milter.
Definition: test.py:41
def setconn(s)
Set the socket used to communicate with the MTA.
Definition: milter.py:227
def _helo(self, helo)
Definition: testctx.py:186
def _feedFile(self, fp, sender="spam@adv.com", rcpt="victim@lamb.com", *rcpts)
Feed a file like object to the ctx.
Definition: testctx.py:254
def send_dsn(mailfrom, receiver, msg=None, timeout=600, session=None, ourfrom='')
Send DSN.
Definition: dsn.py:93
_sender
The MAIL FROM for the current email being fed to the milter.
Definition: testctx.py:47
def unknown_endtag(self, tag)
Definition: sgmllib.py:456
def quarantine(self, reason)
Quarantine the message.
Definition: __init__.py:599
cache
Definition: dns.py:36
def __init__(self, verbose=0)
Definition: sgmllib.py:463
_envfromchanged
True if the milter changed the envelope from.
Definition: test.py:39
A logging but otherwise do nothing Milter base class.
Definition: __init__.py:613
def set_envrcpt_callback(cb)
Definition: milter.py:133
def _eoh(self)
Definition: testctx.py:224
cache
Definition: cache.py:58
_addrcpt
List of recipients added.
Definition: test.py:29
_protocol
Definition: test.py:22
def getencoding(self)
Definition: mime.py:253
def _data(self)
Definition: testctx.py:213
def __getitem__(self, sender)
Definition: cache.py:127
_stage
Definition: testctx.py:157
_sender
The MAIL FROM for the current email being fed to the milter.
Definition: test.py:25
scan_html
Definition: mime.py:377
def quarantine(self, reason)
Calls smfi_quarantine.
Definition: milter.py:105
Definition: greysql.py:15
def _convert_ref(self, match)
Definition: sgmllib.py:300
def has_key(self, sender)
Definition: cache.py:115
def set_envfrom_callback(cb)
Definition: milter.py:132
def delrcpt(self, rcpt)
Calls smfi_delrcpt.
Definition: milter.py:96
def check_attachments(msg, check)
Definition: mime.py:360
defaults
Definition: config.py:8
_ctx
The low level milter.milterContext object.
Definition: __init__.py:244
def parse_addr(t)
Definition: utils.py:171
def inet_ntop(s)
Definition: pyip6.py:16
entitydefs
Definition: sgmllib.py:415
_body
The message body.
Definition: testctx.py:39
def hello(self, hostname)
Called when the SMTP client says HELO.
Definition: __init__.py:629
def setsymlist(self, stage, macrolist)
Tell the MTA which macro values we are interested in for a given stage.
Definition: milter.py:118
entity_or_charref
Definition: sgmllib.py:62
Definition: greylist.py:35
def progress(self)
Tell the MTA to wait a bit longer.
Definition: __init__.py:607
def set_payload(self, val, charset=None)
Definition: mime.py:285
def _negotiate(self)
Definition: testctx.py:152
msg
Definition: mime.py:491
def parse_pi(self, i)
Definition: sgmllib.py:222
def message_from_file(fp)
Definition: mime.py:309
_bodyreplaced
True if the milter replaced the message body.
Definition: test.py:35
__starttag_text
Definition: sgmllib.py:73
def progress(self)
Calls smfi_progress.
Definition: milter.py:107
def register(name, negotiate=None, unknown=None, data=None)
Register python milter with libmilter.
Definition: milter.py:174
Definition: sgmllib.py:60
_macros
Macros defined.
Definition: test.py:31
def addheader(self, field, value, idx=-1)
Add a mail header field.
Definition: __init__.py:507
def close(self)
Definition: sgmllib.py:106
Definition: sgmllib.py:44
greylist_retain
Definition: greylist.py:41
_envfromchanged
True if the milter changed the envelope from.
Definition: testctx.py:49
def eom(self)
Called at the end of the message body.
Definition: __init__.py:661
def addrcpt(self, rcpt, params=None)
Add a recipient to the message.
Definition: __init__.py:540
headerchange
Definition: mime.py:187
dbp
Definition: greylist.py:42
_savname
Definition: mime.py:392
Fix multipart handling in email.Generator.
Definition: mime.py:134
def setsymval(self, name, val)
Set a macro value.
Definition: test.py:57
def finish_shorttag(self, tag, data)
Definition: sgmllib.py:324
def feed(self, data)
Definition: sgmllib.py:95
Definition: milter.py:120
_protocol
Definition: testctx.py:164
lockname
Definition: plock.py:19
_msg
The rfc822 message object for the current email being fed to the milter.
Definition: test.py:43
def main()
Transfer control to libmilter.
Definition: milter.py:190
def setpriv(self, priv)
Attach a Python object to this connection context.
Definition: milter.py:101
modified
Definition: mime.py:490
def log(self, *msg)
Provide simple logging to sys.stdout.
Definition: __init__.py:617
def handle_charref(self, name)
Definition: sgmllib.py:406
def _chk_name(self, msg)
Definition: mime.py:379
def param2dict(str)
Convert ESMTP parm list to keyword dictionary.
Definition: __init__.py:731
greylist_retain
Definition: greysql.py:21
def hello(self, hostname)
Called when the SMTP client says HELO.
Definition: __init__.py:322
umis
Definition: greylist.py:27
fname
Definition: cache.py:59
def body(self, blk)
Called to supply the body of the message to the Milter by chunks.
Definition: __init__.py:360
def setnomoretags(self)
Definition: sgmllib.py:81
def dns(self, name, qtype, cnames=None)
Cached DNS lookup.
Definition: dns.py:60
def finish_endtag(self, tag)
Definition: sgmllib.py:349
def unknown_starttag(self, tag, attrs)
Definition: sgmllib.py:455
def set_helo_callback(cb)
Definition: milter.py:131
def nocallback(func)
Function decorator to disable callback methods.
Definition: __init__.py:144
def header_leading_space(klass)
Milter leading space on headers.
Definition: __init__.py:132
_macros
Macros defined.
Definition: testctx.py:33
def __init__(self, verbose=0)
Definition: sgmllib.py:66
def replacebody(self, data)
Calls smfi_replacebody.
Definition: milter.py:98
_bodyreplaced
True if the milter replaced the message body.
Definition: testctx.py:41
ignoreLastByte
Definition: greysql.py:18
def set_flags(flags)
Enable optional milter actions.
Definition: milter.py:128
_stage
The protocol stage for macros returned.
Definition: test.py:45
def eoh(self)
Called at the blank line that terminates the header fields.
Definition: __init__.py:356
_msg
The rfc822 message object for the current email being fed to the milter.
Definition: testctx.py:45
def iniplist(ipaddr, iplist)
Definition: utils.py:64
_symlist
The macros returned by protocol stage.
Definition: test.py:47
Definition: sgmllib.py:461
def handle_starttag(self, tag, method, attrs)
Definition: sgmllib.py:380
def convert_charref(self, name)
Definition: sgmllib.py:393
def _feed_body(self, bfp)
Definition: testctx.py:232
def envrcpt(self, to, *str)
Called when the SMTP client says RCPT TO.
Definition: __init__.py:344
Disabled action exception.
Definition: __init__.py:205
def parseaddr(t)
Split email into Fullname and address.
Definition: utils.py:125
_actions
A bitmask of actions this connection has negotiated to use.
Definition: __init__.py:259
def addheader(self, name, value, idx=-1)
Calls smfi_addheader.
Definition: milter.py:90
greylist_expire
Definition: greysql.py:20
def report_unbalanced(self, tag)
Definition: sgmllib.py:388
ignoreLastByte
Definition: greylist.py:38
conn
Definition: greysql.py:22
def opensocket(rmsock)
Attempt to create the socket used to communicate with the MTA.
Definition: milter.py:185
def getnames(self, scan_zip=False)
Definition: mime.py:207
def connect(self, host='localhost', helo='spamrelay', ip='1.2.3.4')
Call the connect and helo callbacks.
Definition: test.py:222
_check
Definition: mime.py:393
def unlock(self)
Definition: plock.py:59
def unknown(self, cmd)
Called when the SMTP client issues an unknown command.
Definition: __init__.py:365
def _header(self, fld, val)
Definition: testctx.py:221
def connect_callback(ctx, hostname, family, hostaddr, nr_mask=P_NR_CONN)
Connect context if needed and invoke connect method.
Definition: __init__.py:695
cnt
Definition: greylist.py:26
def error(self, message)
Definition: sgmllib.py:110
out
Definition: mime.py:420
def getsymval(self, sym)
Return the value of an MTA macro.
Definition: __init__.py:440
def setbacklog(n)
Set socket backlog.
Definition: milter.py:208
def inet_pton(p)
Definition: pyip6.py:59
def unknown_entityref(self, ref)
Definition: sgmllib.py:458
verbose
Definition: sgmllib.py:68
def get_param(self, param, failobj=None, header='content-type', unquote=True)
Definition: mime.py:189
def eoh(self)
Called at the blank line that terminates the header fields.
Definition: __init__.py:656
def envfrom(self, f, *str)
Definition: __init__.py:635
def chgheader(self, field, idx, value)
Change the value of a mail header field.
Definition: __init__.py:521
Hold context for a milter connection.
Definition: milter.py:77
def set_exception_policy(code)
Sets the return code for untrapped Python exceptions during a callback.
Definition: milter.py:148
greylist_expire
Definition: greylist.py:40
nomoretags
Definition: sgmllib.py:77
def has_precise_key(self, sender)
Definition: cache.py:101
_opts
Negotiated options.
Definition: testctx.py:53