# opendmarc_spf_test()

[back to index]

SYNOPSIS

    #include <dmarc.h>
    int opendmarc_spf_test(
    	char *ip_address, char *mail_from_domain, char *helo_domain,
    	char *spf_record, int softfail_okay_flag, char *human_readable,
    	size_t human_readable_len, int *used_mfrom
    );

Validate a passed in SPF record or look up one and validate it.

DESCRIPTION

Called When | `opendmarc_spf_test()` May be called anytime all its needed information is gathered. The envelope sender (MAIL From: or mlfi_envfrom) is the earliest it can be called. The mlfi_eom() is the optimum time because that is the only routine that can add a header.

ARGUMENTS

Argument | Description
--- | ---
ip_address | A pointer to a string representation of an IPv4 or IPv6 address.
mail_from_domain | This can be the domain itself, or the full sender address or even the angle brace enclosed address. Any of of those will work, including the empty address <> and the literal MAILER_DAEMON.
helo_domain | This is the domain specified with the HELO command. This domain is ignored if the mail_from_domain contains an actual domain.
spf_record | If not NULL, is a string containing the SPF record to validate. If NULL, the record will be looked up based on either the `mail_from_domain` or `helo_domain`/.
softfail_okay_flag | If zero softfails (~all and ?all) are treated the same as if the are hard fails. If non-zero, softfails are threated as a pass.
human_readable | If not NULL, is the address of a string buffer into which to scribble a human readble reason for any result.
human_readable_len | The sizeof() or number of characters available in `human_readable`.
used_mfrom | Address of an integer into which either TRUE or FALSE will be written. If TRUE, the `mail_from_domain` was used to validate the SPF record. If FALSE, the `helo_domain` was used to validate the SPF record.

RETURN VALUES

- `DMARC_POLICY_SPF_OUTCOME_PASS` -- On success
- `DMARC_POLICY_SPF_OUTCOME_FAIL` -- If the SPF record check failed.
- `DMARC_POLICY_SPF_OUTCOME_TMPFAIL` -- If there was as recoverable failure.
- `DMARC_POLICY_SPF_OUTCOME_NONE` -- If domain did not have an spf record.

NOTES

- This spf record check performs it own DNS lookups. There are no hooks provided to subsitute your own DNS lookup routines at this time.

Copyright (c) 2012, The Trusted Domain Project. All rights reserved.
By using this file, you agree to the terms and conditions set forth in the license.