Sending SMS messages using your own phone number without incurring extra costs is challenging due to the infrastructure and agreements required with telecom providers. However, there are a few approaches you might consider:
-
Email-to-SMS Gateways: Some carriers offer email-to-SMS gateways, where you can send an email to a specific address, and it will be delivered as an SMS to the recipient. This method is often free but requires knowing the recipient's carrier and their specific gateway address.
-
Using a SIM Card with a GSM Modem: You can use a GSM modem with a SIM card from your phone plan. This setup allows you to send SMS messages programmatically using your own number. However, this might still incur costs depending on your mobile plan.
-
Third-Party Services: While you mentioned wanting to avoid costs, using services like Twilio, Nexmo, or Plivo is the most straightforward way to send SMS messages programmatically. These services often allow you to set up a virtual number, but using your own number might not be possible without additional costs.
-
Custom Android/iOS App: You could develop a custom app that runs on your phone and uses its SMS capabilities to send messages. This would require the phone to be connected to the internet and might still incur costs depending on your mobile plan.
Here's a basic example of how you might use a GSM modem with a Python script to send an SMS:
import serial
def send_sms(phone_number, message):
# Configure the serial port
ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1)
ser.write(b'AT\r')
ser.write(b'AT+CMGF=1\r') # Set SMS mode to text
ser.write(f'AT+CMGS="{phone_number}"\r'.encode())
ser.write(f'{message}\x1A'.encode()) # \x1A is the ASCII code for Ctrl+Z
response = ser.read_all()
ser.close()
return response
# Example usage
response = send_sms('+31612345678', 'Hello from my GSM modem!')
print(response)
Note: This example assumes you have a GSM modem connected to your computer and the necessary drivers installed. The serial port (/dev/ttyUSB0) and baud rate (9600) might need to be adjusted based on your setup.
Keep in mind that any solution involving your own number will depend heavily on your mobile carrier's policies and the capabilities of your mobile plan.