Send SMS from the Mac terminal
Install the sparetext command-line tool, pair it as a Mac relay, and run sparetext send --to +12025550123 --text "Hello". The text goes out through Messages from your iPhone's own number, by Text Message Forwarding, and sparetext wait returns the reply.
Install and pair
One universal binary for Apple silicon and Intel, macOS 11 or later, with Messages signed in to the Apple Account your iPhone uses. Turn on Text Message Forwarding for this Mac on the iPhone first.
unzip sparetext-macos.zip && cd sparetext-macos
xattr -d com.apple.quarantine sparetext
sudo mkdir -p /usr/local/bin && sudo mv sparetext /usr/local/bin/
sparetext relay pair K7Q4M2 # the code from Phones › Add phone › iPhone + Mac relay
sparetext relay doctor # checks everything without sending
sparetext relay install # starts at loginSend, wait for the reply, read the thread
The same commands work in shell scripts, cron jobs and AI agents. --json gives output a program can read; wait exits with 2 on timeout.
export SPARETEXT_API_KEY=spt_live_...
sparetext send --to +12025550123 --text "The build finished"
sparetext wait --contact +12025550123 --timeout 300
sparetext messages --contact +12025550123 --jsonSMS or iMessage
The relay sends SMS by default. --service imessage sends iMessage instead, and --service auto tries SMS first and falls back to iMessage. Pass it to relay install.
Why not AppleScript alone?
A one-line osascript can hand a text to Messages, but it doesn't say whether the text went out, doesn't read replies, and only works on the Mac where it runs. The relay confirms each send from Messages' own database, reads replies, names the reason when a send fails, and lets a script or agent anywhere send through this Mac with an API key.
Questions people ask
- Do I need an iPhone?
- For SMS, yes: Messages on a Mac sends SMS through an iPhone with Text Message Forwarding. Without one, the relay can send iMessage to Apple devices only.
- Does the Mac need to stay on?
- Yes, awake and signed in, for the relay to send. Texts queued while it sleeps wait and go out when it's back.
- Can I send from a script on another computer?
- Yes. Any script with your API key can call the REST API or the sparetext CLI from anywhere; the Mac relay is the phone that sends.