Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pitt.edu #52

Open
editorassistant opened this issue May 30, 2023 · 6 comments
Open

pitt.edu #52

editorassistant opened this issue May 30, 2023 · 6 comments

Comments

@editorassistant
Copy link

getIPStringResult("52.70.139.219", "pitt.edu")

leads to an preg_split(): Argument #2 ($subject) must be of type string error.

@Mika56
Copy link
Owner

Mika56 commented May 30, 2023

Your query is missing a value for the $helo argument. While not strictly required, because the SPF of pitt.edu is v=spf1 include:%{i}._ip.%{h}._ehlo.%{d}._spf.vali.email ~all, it tries to resolve 52.70.139.219._ip.._ehlo.pitt.edu._spf.vali.email which is an invalid domain name (notice the two dots in the middle, where the value of $helo would be added).

I'm not sure if the library should provide a default value, make it mandatory, add a warning to SPFResult when %{h} or %{s} is used in a SPF record and not set in the query, or throw an Exception?

@editorassistant
Copy link
Author

I'm confused. The signature for getIPStringResult is getIPStringResult(string $ipAddress, string $domain), i.e., there is no "helo" argument.

@derikb
Copy link

derikb commented Oct 5, 2023

Just had this come up for rush.edu and am also a little confused about where the helo argument goes and... what one would put in there...

@derikb
Copy link

derikb commented Oct 5, 2023

Found some syntax info here: https://www.jamieweb.net/blog/using-spf-macros-to-solve-the-operational-challenges-of-spf/#macro-syntax Looks to me like outside the context of processing a specific message you wouldn't be able to check spf records with these variables unless you also had some IP info.

@derikb
Copy link

derikb commented Oct 5, 2023

Throwing an Exception might be cleanest when this happens.

@Mika56
Copy link
Owner

Mika56 commented Oct 9, 2023

I'm confused. The signature for getIPStringResult is getIPStringResult(string $ipAddress, string $domain), i.e., there is no "helo" argument.

getIPStringResult is the easier way to get a result. If you need advanced features like ehlo string or sender email, create a Query object directly:

<?php

$checker = new SPFCheck(new DNSRecordGetter());
$query = new Query($ipAddress, $domain, $ehlo, $sender);
$result = $checker->getResult($query);
var_dump($result->getShortResult()); // One of + - ~ ? NO TE PE
var_dump($result->getResult()); // One of Result::PASS, Result::FAIL, Result::SOFTFAIL, Result::NEUTRAL, Result::NONE, Result::TEMPERROR, Result::PERMERROR

Found some syntax info here: https://www.jamieweb.net/blog/using-spf-macros-to-solve-the-operational-challenges-of-spf/#macro-syntax Looks to me like outside the context of processing a specific message you wouldn't be able to check spf records with these variables unless you also had some IP info.

Yes, EHLO and Sender are used in macros, which aren't widely used.

Throwing an Exception has the disadvantage of stopping the execution of the check. I feel like a better solution would be to add a hasWarning() method to Result.
We could also add an option to SPFCheck: bool $throwExceptionOnMissingMacroArgument = false (but a developer explicitly changing it to true would then probably already be aware of the $ehlo and $sender arguments)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants