NAME
Mail::SPF::Result - SPF result class
SYNOPSIS
For the general usage of Mail::SPF::Result objects in code that calls Mail::SPF, see Mail::SPF. For the detailed interface of Mail::SPF::Result and its derivatives, see below.
Throwing results
package Mail::SPF::Foo;
use Error ':try';
use Mail::SPF::Result;
sub foo {
if (...) {
throw Mail::SPF::Result::Pass($request);
}
else {
throw Mail::SPF;;Result::PermError($request, 'Invalid foo');
}
}
Catching results
package Mail::SPF::Bar;
use Error ':try';
use Mail::SPF::Foo;
try {
Mail::SPF::Foo->foo();
}
catch Mail::SPF::Result with {
my ($result) = @_;
my $code = $result->code;
my $request = $result->request;
my $text = $result->text;
};
DESCRIPTION
An object of class Mail::SPF::Result represents the result of an SPF request.
There is usually no need to construct an SPF result object directly using the new
constructor. Instead, use the throw
class method to signal to the calling code that a definite SPF result has been determined. In other words, use Mail::SPF::Result and its derivatives just like exceptions. See Error or "eval" in perlfunc for how to handle exceptions in Perl.
Constructor
The following constructor is provided:
- new($request): returns Mail::SPF::Result
- new($request, $text): returns Mail::SPF::Result
-
Creates a new SPF result object and associates the given Mail::SPF::Request object with it. An optional result text may be specified.
Class methods
The following class methods are provided:
- throw($request): throws Mail::SPF::Result
- throw($request, $text): throws Mail::SPF::Result
-
Throws a new SPF result object, associating the given Mail::SPF::Request with it. An optional result text may be specified.
- code: returns string
-
Returns the result code (
"pass"
,"fail"
,"softfail"
,"neutral"
,"none"
,"error"
,"permerror"
,"permerror"
) of the Mail::SPF::Result::* class on which it is invoked. This method may also be used as an instance method. - class_by_code($code): returns class
-
Maps the given result code to the corresponding Mail::SPF::Result::* class. If an unknown result code was specified, returns undef.
- is_code($code): returns boolean
-
If the class (or object) on which this method is invoked represents the given result code (or a derivative code), returns true. Returns false otherwise. This method may also be used as an instance method.
For example,
Mail::SPF::Result::Pass->is_code('pass')
returns true.
Instance methods
The following instance methods are provided:
- throw: throws Mail::SPF::Result
- throw($request): throws Mail::SPF::Result
- throw($request, $text): throws Mail::SPF::Result
-
Re-throws an existing SPF result object. If a Mail::SPF::Request object is specified, associates it with the result object, replacing the prior request object. If a result text is specified as well, overrides the prior result text.
- code: returns string
-
Returns the result code of the result object.
- request: returns Mail::SPF::Request
-
Returns the SPF request that led to the result at hand.
- text: returns string
-
Returns the text message of the result object.
RESULT CLASSES
The following result classes are provided:
- Mail::SPF::Result::Pass
- Mail::SPF::Result::Fail
-
The following additional instance method is provided:
- explanation: returns MacroString
-
Returns the explanation for the
fail
result as a MacroString object, which may be used as a string. Be aware that the explanation is provided by a potentially malicious party and thus should not be trusted. See RFC 4408, 10.5, for a more detailed discussion of this issue.
- Mail::SPF::Result::SoftFail
- Mail::SPF::Result::Neutral
- Mail::SPF::Result::NeutralByDefault
-
This is a special-case of the
neutral
result that is thrown as a default when "falling off" the end of the record during evaluation. See RFC 4408, 4.7. - Mail::SPF::Result::None
- Mail::SPF::Result::Error
-
The following sub-classes of Mail::SPF::Result::Error are provided:
SEE ALSO
Mail::SPF, Mail::SPF::Server, Error, "eval" in perlfunc
http://www.ietf.org/rfc/rfc4408.txt
For availability, support, and license information, see the README file included with Mail::SPF.
AUTHORS
Julian Mehnle <julian@mehnle.net>
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 334:
alternative text 'http://www.ietf.org/rfc/rfc4408.txt' contains non-escaped | or /