Can I message to anyone?

Yes, But if the user disables this privacy feature ‘Allow you to send and receive messages from people who are not on your network‘ then you will not be able to message. you should connect and message that user.

Note:- By default that privacy feature is enabled for everyone.