First you have to register with Indian Railway (IRCTC). Then  Registered users (Indian Railway Catering and Tourism Corporation Limited) can book their train tickets through a simple text-messaging-based-SMS facility or a menu-based dialing service.

For SMS Bookings, users need to send a Booking SMS in specified format with information of date of journey, class , train number and passenger details.

After this, one shall receive a seat availability information. In the second SMS, users can make the payment which can be initiated in two ways. The Booking confirmation SMS will be sent by the IRCTC.

Instructions pertaining to the train bookings through SMS-

Find it here