The trains in Morocco operate very frequently and are quite cheap, although you have to pay an extra fee for waggons with air condition.
Unfortunately, you can't travel directly Essaouira by train. You can only go as far as Marrakesh. From here, take the bus down the coast to Essaouira.
The Moroccan railway system is quite efficient. Trains run on time and tickets are very cheap. Although, if you want an air conditioned carriage, you'll have to pay a supplement. The train journey is relatively fast, reliable and comfortable. You can buy a first or second class ticket. It's better to buy second class because it's cheaper and the carriages are just as comfortable. It's possible to buy your ticket just before you get on the train. You don't even have to reserve a place. You'll find all the information you need (shedules, routes and prices) on the Moroccan railroads website (ONCF).
In tangiers you can buy a combined ticket for the train to Marrakesh and the bus to Essaouira. A second class ticket costs 150 dh and a first class ticket will cost you 250 dh.
Here in Costasur.com you can find guides and tourist information for many destinations, you can also reserve accommodation, transport or activities for your holidays. We are specialists in accommodation with more than 75,000 hotels and apartments in more than 900 destinations.