├── requirements.txt ├── README.md └── main.py /requirements.txt: -------------------------------------------------------------------------------- 1 | twilio==7.14.0 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🌐 Sending SMS with Python 2 | ## Know more ways? Create a pull request! 3 | --- 4 | More interesting projects: - https://netstalkers.com/private 5 | 6 | ### 🎥 [PYTHON:TODAY](https://www.youtube.com/c/PythonToday/videos) 7 | ### 🔥 [Telegram](https://t.me/python2day) 8 | --- 9 | ``` 10 | $ pip install twilio 11 | ``` 12 | or 13 | 14 | ``` 15 | $ pip install -r requirements.txt 16 | ``` 17 | --- 18 | 19 | [Code](https://github.com/pythontoday/sending_sms/blob/master/main.py) 20 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from twilio.rest import Client 2 | import os 3 | 4 | 5 | def sending_sms(text='Wake up Neo...', receiver='+89876540000'): 6 | 7 | try: 8 | account_sid = os.getenv('SID') 9 | auth_token = os.getenv('AUTH_TOKEN') 10 | 11 | client = Client(account_sid, auth_token) 12 | 13 | message = client.messages.create( 14 | body=text, 15 | from_='sender_phone_number', 16 | to=receiver 17 | ) 18 | 19 | return 'The message was successfully sent!' 20 | except Exception as ex: 21 | return 'Something was wrong... :(', ex 22 | 23 | 24 | def main(): 25 | text = input('Please enter your message: ') 26 | print(sending_sms(text=text, receiver=os.getenv('RECEIVER_PHONE'))) 27 | 28 | 29 | if __name__ == '__main__': 30 | main() 31 | --------------------------------------------------------------------------------