For one of my Pi projects I wanted the ability to send SMS text messages from a Python script. These messages would be sent to my mobile phone and alert me about specific events recorded by my Pi. There was no possibility of connecting the Pi to a mobile phone so I decided to send the SMS via the internet.
In previous years there were services that allowed you to send free text messages via the Internet. In general these services were either illegal or relied on loopholes in mobile phone networks that have since been fixed.
So the only reliable solution is to use an SMS Gateway.