Emma is right on ...
'.. is not connected to whatever email you are using as the address that is sending the email."
Makes no difference as to Moodle version ... since moodle code isn't a true mail server ... one could configure SMTP or not, once the messages are packaged up and phpmailer or localhost sends to SMTP server that message has, like Elvis, 'left the building', Now it's up to something other than Moodle.
Regardless of where you host your moodle, *all* hosting providers do NOT want their services to be a haven for 'spam kings/queens'. Some hosting providers actually list their own servers in SpamHause - or a range of IPv4 servers.
So to have the best chance of mail never being tagged as spam, one has to set up SPF DNS records for the moodle server to be known as a valid sending mail server for the domain. Not only SPF records, but DKIM, and DMARC are also being used for defenses.
To test DNS and EMail related records in DNS for your domain/moodle server, suggest using:
Even if one gets all (SPF/DKIM/DMARC/MX) still some receiving mail servers might still tag messages from the moodle ... due to content.
It really is a 'best effort'.
The ONLY way one can assure delivery is to force your students/teachers to use an EMail service that you provide ... you are then in control of both ends ... the moodle end (sending) and of course the receiving end ... the mail server you are providing.
Can tell ya this as a former mail server admin .. that's a full time job ... and you've got better things to do!