PHP-SPF-Check icon indicating copy to clipboard operation
PHP-SPF-Check copied to clipboard

Result details

Open Pascal76 opened this issue 9 years ago • 5 comments

It would be nice to have details ex1: what validated the spf (ip4:xxx / a / mx / include => ip4:xxx ...) ex2: full list of authorized IPs + others non IP which are authorized too

Pascal76 avatar Aug 30 '16 16:08 Pascal76

Hi, This is on the list of things I want to do once v1 is out ( #6 ). What I was thinking was to keep the isIpAllowed as it is (returns one of the consts), but add a method like getDetailedResults which would return an object of class SPFResult, having the following methods:

<?php
namespace Mika56\SPFCheck;

class SPFResult
{
    /**
     * @return string The check result
     */
    abstract public function getResult();

    /**
     * @return string The whole SPF record the IP was queried against
     */
    abstract public function getSPFRecord();

    /**
     * @return string The part that matched the IP
     */
    abstract public function getMatchingPart();

    /**
     * @return bool whether the request was redirected or not
     */
    abstract public function wasRedirected();

    /**
     * @return string|null The reason why the check resulted in FAIL
     */
    abstract public function getExp();
}

Do you see any other method that could be added? I also wonder how to handle redirections, would the SPFResult class embed as many SPFResult as there was redirect and include parts?

Mika56 avatar Aug 30 '16 17:08 Mika56

just the Full list of authorized IPs From my side you helped me a lot for my email deliverabily software (3 years project) If you have new time to spent for a project you can help me on it :)

Pascal76 avatar Aug 30 '16 21:08 Pascal76

Problem I see with the full list of allowed IP addresses is that we stop processing as soon as a mechanism matches... I think if you want to get the full list of IP addresses allowed, this would be a dedicated method. If my understanding of the norm is correct, results would also be incomplete when ptr mechanism is used (through I just read it is not recommended to use ptr since RFC7208).

Sadly I'm more than lacking time to start new projects (and continue current projects :smile: ), but I'm glad I was able to help you!

Mika56 avatar Aug 30 '16 21:08 Mika56

Version 2 was just released and now allows you to get a Result object with details on how the result was obtained. Is this enough for your first point?

Mika56 avatar Aug 28 '22 15:08 Mika56

Hello @Mika56 It looks great but I migrated to https://github.com/mlocati/spf-lib to benefit the OnlineSemanticValidator function I will do tests when I have some time Thank you

Pascal76 avatar Aug 28 '22 17:08 Pascal76