slimta.util.spf¶
This module provides classes to check the SPF records of the sending client address.
- class slimta.util.spf.EnforceSpf([timeout=10.0])¶
Bases:
object
Class used to check SPF records and enforce a policy against the results. By default, results are logged but not acted upon.
- Parameters
timeout – Timeout in seconds before giving up the check. An SPF check that times out is equivalent to a
'temperror'
result.
- set_enforcement(result[, match_code='550'[, match_message='5.7.1 Access denied']])¶
Adds an enforcement policy to a particular SPF result. If the given result is seen, the
MAIL FROM
reply is set accordingly.- Parameters
result – The result code, one of
'pass'
,'permerror'
,'fail'
,'temperror'
,'softfail'
,'none'
,'neutral'
.match_code – When the result code matches, set the
Reply
code to this string.match_message – When the result code matches, set the
Reply
message to this string. You can use the{reason}
template in your string.
- query(sender, ip, ehlo_as)¶
Performs a direct query to check the sender’s domain to see if the given IP and EHLO string are authorized to send for that domain.
- Parameters
sender – The sender address.
ip – The IP address string of the sending client.
ehlo_as – The EHLO string given by the sending client.
- Returns
A tuple of the result and reason strings.
- check(f)¶
Decorates
SmtpValidators
methods that are given aReply
object. It will check the current SMTP session’s connecting IP address and EHLO string against the given sender address. If enforcement policies are set for the result, theReply
is modified before calling the validator method.This decorator can only be used on
handle_mail()
,handle_rcpt()
, andhandle_data()
.- Parameters
f – The overloaded
SmtpValidators
method to decorate.