Symptoms
Emails to Gmail get bounced with one of the errors below:
This message does not pass authentication checks (SPF and DKIM both 550-5.7.26 do not pass). SPF check for [example.com] does not pass with ip: 550-5.7.26 [203.0.113.2].
The MAIL FROM domain [example.com] has an SPF record with an5.7.26 hard fail policy (-all) but it fails to pass SPF checks with the ip:n5.7.26 [203.0.113.2].
Cause
The IP address from the error is not allowed to send email on behalf of the domain.
According to the official Gmail documentation: "if third-party senders aren't included in the SPF record, messages sent from these providers are more likely to be marked as spam".
Resolution
Configure the SPF record to include the IP address from the message, depending on how DNS settings are managed: