CMailMessage::CheckAuthenticationResults Method  
 
BOOL CheckAuthenticationResults(
  DWORD dwAuthFlags  
);

The CheckAuthenticationResults method checks if the authentication status in the message matches one or more values.

Parameters

dwAuthFlags
A bitmask that specifies one or more authentication flags to check for. These can be any combination of the values listed below.
Value Description
MIME_AUTH_SPF_PASSED The message passed the Sender Policy Framework (SPF) check. The sender's IP address was authorized to send mail for the domain in the envelope sender address.
MIME_AUTH_SPF_FAILED The message failed the SPF check. The sending mail server is not authorized by the domain's SPF record to send mail on its behalf.
MIME_AUTH_DKIM_PASSED The message passed the DomainKeys Identified Mail (DKIM) check. The signature applied by the sender was successfully verified using the domain's public key.
MIME_AUTH_DKIM_FAILED The message failed the DKIM check. The signature could not be verified or did not match the message content, suggesting it may have been altered.
MIME_AUTH_DMARC_PASSED The message passed DMARC evaluation. The message aligned with a valid SPF or DKIM result based on the sender domain's policy.
MIME_AUTH_DMARC_FAILED The message failed DMARC evaluation. It did not pass SPF or DKIM checks in a way that aligns with the domain's published policy.
MIME_AUTH_TEMP_ERROR A temporary error occurred while evaluating one or more authentication mechanisms. This may indicate a DNS lookup timeout or other transient failure.
MIME_AUTH_PERM_ERROR A permanent error occurred during authentication checks. This may indicate a malformed DNS record or invalid message structure that prevents proper evaluation.

Return Value

This method returns a non-zero value if one or more of the specified flags match the values found in the message's Authentication-Results header. If there is no match, the method returns zero. This method explicitly clears the last error code to assist in differentiating between an actual error condition (such as an invalid message handle) and a case where no authentication data matched.

Remarks

This method provides a convenient way to check if the authentication status of the message matches one or more values. In addition to the flags specified above, the following predefined flag combinations are also available:

  • MIME_AUTH_PASSED is a combination of all passing results (SPF, DKIM, DMARC).
  • MIME_AUTH_FAILED is a combination of all failing results.
  • MIME_AUTH_ERROR is a combination of temporary or permanent errors.

This method allows for quick checks against common authentication outcomes using predefined flags. For example, to check whether the message failed authentication or encountered a temporary error, you could specify MIME_AUTH_FAILED | MIME_AUTH_TEMP_ERROR.

For more information about SPF, DKIM and DMARC, please refer to the GetAuthenticationResults method.

Example

if (mailMessage.Open(lpszFileName))
{
    // Check if any of the SPF, DKIM, or DMARC checks failed
    if (mailMessage.CheckAuthenticationResults(MIME_AUTH_FAILED))
        _tprintf(_T("This message has failed one or more authentication checks\n"));

    mailMessage.Close();
}

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csmsgv12.lib

See Also