Friday, January 24, 2014

Send Text Messages (email) from a Linux Terminal

     I made the switch from Windows 7 to Linux about a year and a half ago.  Since then I've wandered through a handful of different distributions.  I started with Linux Mint and have grown very comfortable with Arch Linux over the past six months.  This isn't a post comparing and contrasting different "flavors" of Linux -- though that might be a good endeavor in the future -- but rather a nifty little process of sending text messages (via gmail) from my Linux terminal (command prompt).  The following are the steps involved; though they are distro specific to Arch, the same concept can be applied you distro of choice (Ubuntu, Mint, Fedora, etc...).

First, you'll need to download a small application called "mailx", so enter a terminal and ...
$ sudo pacman -S mailx
...then do some configuring for the application (can also use "gedit" or "vim" or your text editor of choice instead of "nano").
$ sudo nano /etc/mail.rc
Delete the contents of the file and add the following:
set sendmail="/usr/bin/mailx"
set smtp=smtp.gmail.com:587
 set smtp-use-starttls
 set ssl-verify=ignore
set ssl-auth=login
set smtp-auth-user=YourEmailAddress@gmail.com
set smtp-auth-password=YourGmailPassowrd
The basic process is something like this ...
$ mailx 10digitphonenumber@carrier.com [enter]
Enter message subject if desired [enter]
Enter message body
Press [Ctrl+d] to send
Alternatively its a bit more sleek and simple to just do...
$ echo "message contents" | mailx 10digitphonenumber@carrier.com 
There are also other arguments you can include; such as...
$ echo "message contents" | mailx -S [Message Subject] 10digitnumber@carrier.com
$ echo "message contents" | mailx -c [Carbon Copy recipient] 10digitphonenumber@carrier.com 
$ echo "message contents" | mailx -S [Message Subject] -c [CC recipient] 10digitphonenumber@carrier.com
Voila!  Your recipient will receive a text message from your Gmail address.  Here is a list of carriers and their respective message clients:
  • Verizon: 10digitphonenumber@vtext.com
  • AT&T: 10digitphonenumber@txt.att.net
  • Former AT&T customers: 10digitphonenumber@mmode.com
  • Sprint: 10digitphonenumber@messaging.sprintpcs.com
  • T-Mobile: 10digitphonenumber@tmomail.net
  • Nextel: 10digitphonenumber@messaging.nextel.com
  • Cingular: 10digitphonenumber@cingularme.com
  • Virgin Mobile: 10digitphonenumber@vmobl.com
  • Alltel: 10digitphonenumber@alltelmessage.com OR
  • 10digitphonenumber@message.alltel.com
  • CellularOne: 10digitphonenumber@mobile.celloneusa.com
  • Omnipoint: 10digitphonenumber@omnipointpcs.com
  • Qwest: 10digitphonenumber@qwestmp.com
  • Telus: 10digitphonenumber@msg.telus.com
  • Rogers Wireless: 10digitphonenumber@pcs.rogers.com
  • Fido: 10digitphonenumber@fido.ca
  • Bell Mobility: 10digitphonenumber@txt.bell.ca
  • Koodo Mobile: 10digitphonenumber@msg.koodomobile.com
  • MTS: 10digitphonenumber@text.mtsmobility.com
  • President's Choice: 10digitphonenumber@txt.bell.ca
  • Sasktel: 10digitphonenumber@sms.sasktel.com
  • Solo: 10digitphonenumber@txt.bell.ca

No comments:

Post a Comment