Thailand has one of the best metre-gauge rail systems in the world, and train travel is easily the best way to get around & see the country. Train travel in Thailand is comfortable, safe, cheap, environmentally friendly. And unlike flying, it's a genuine Thai experience making the journey as much a part of your trip as the destination.
Trains leave Bangkok frequently and you have bus to bring you to the pier to Koh Samui or Koh Phangan. The best way is to take a sleeper on an overnight train.
The State Railways of Thailand provide three classes of accommodation: 1st, 2nd and 3rd class. The 1st class is expensive, with a private room, the 2nd class is very comfortable, definetly the best deal, and the 3rd class is clean and acceptable but really tiring for the longer journeys.
You can buy joint ticket including train and boat to Koh Phangan at most travel agencies in Bangkok and in the train station. And the same tickets are offered here to go back to Bangkok. There are free buses to bring you from/to the pier to/from Suratthani town, airport or train station.
Check the latest prices and schedules via the service link on the website of The State Railway of Thailand...