smtp – SPF SOFTFAIL domain of transitioning XX@company.com does not designate X.X.X.X as permitted sender)

in my company I have the following error.

softfail (google.com: domain of transitioning someone@company.com does not designate X.X.X.X as permitted sender) client-ip=X.X.X.X;

Let’s say my mail.company.com server is Y.Y.Y.Y, every user connects to his/her mail account from Thunderbird, the SMTP/POP3/IMAP is served by DirectAdmin hosted on Y.Y.Y.Y domain. Some of users who uses GMail to download mails from external POP3 server (mail.company.com) are receiving the above error and email is in SPAM directory. The SPF record which I had was:

v=spf1 a mx ip4:Y.Y.Y.Y ~all

The thing which I don’t understand is how is it possible that IP marked as designated IP is X.X.X.X and it differs sometimes but still it’s not SMTP server’s ip Y.Y.Y.Y?
I changed SPF record to:

v=spf1 mx a ptr ~all

But I don’t this it’s the best solution.
I have my domain stored behind cloudflare but mail.company.com is not proxied only company.com is proxied.
Thank you for any help.