This is a simple script that uses the Termux API to forward new SMS messages from your Android phone to an email address.
Instead of forwarding SMS messages directly via SMS, this script sends them over email. This is a personal decision based on my situation, where:
- My phone can still receive SMS for free
- Sending SMS is expensive
- I have Wi-Fi or mobile data available
Make sure the following Termux components are installed and properly configured on your Android device. Additionally, grant Termux:API the necessary permissions for Contacts and SMS.
All setup steps below should be executed inside the Termux terminal.
If Git is not installed:
apt update
apt install gitThen, clone this repository:
cd ~
git clone https://github.com/Rockruff/SMS-Forward.gitNavigate to the project folder and edit the configuration file:
cd ~/SMS-Forward
nano config.smtp.json # Or use any text editorFill in the SMTP settings. Example (using Gmail):
{
"server": "smtp.gmail.com",
"port": 465,
"sender": "someone@gmail.com",
"password": "0123456789abcdef",
"recipient": "someone@icloud.com"
}Field explanations:
server: SMTP server address (e.g.,smtp.gmail.comfor Gmail)port: SMTP port (use465for SSL)sender: Email address used to send the forwarded SMSpassword: Password for the sender account. Gmail users must use an app-specific passwordrecipient: Email address to receive the forwarded SMS messages
If Python is not installed:
apt install python3Run the script:
python3 main.pyThe script will only forward new SMS messages received after it starts. Messages that are already in your inbox will not be forwarded. You might want to send a test SMS to your phone to confirm everything is working.
To make the script run automatically at boot using Termux:Boot:
-
Create the
bootdirectory if it doesn't exist:mkdir -p ~/.termux/boot -
Create and edit a startup script:
cd ~/.termux/boot nano start-sms-forward
-
Add the following contents to the script:
#!/data/data/com.termux/files/usr/bin/sh termux-wake-lock nohup bash -c 'cd ~/SMS-Forward && python3 main.py' &
-
Make the script executable:
chmod +x start-sms-forward
Reboot your phone. The script should start automatically and forward any new incoming SMS via email.
You may need to unlock your phone to see the script's notifications.