The prefix HMS before a ship's name stands for Her (or "His" if a King is on the throne) Majesty's Ship and is a designation reserved for British ships in military service such as the ships of the Royal Navy. The Titanic was a civilian ship crewed by civilians and therefore not a military ship. Her designation as RMS Titanic meant she was a ship under contract to the British postal authorities (i.e. The Royal Mail) to carry mail on behalf of the Post Office. RMS = Royal Mail Ship.
From Wikipedia:
Royal Mail Ship (sometimes Steam-ship or Steamer), usually seen in its abbreviated form RMS, a designation which dates back to 1840, is the ship prefix used for seagoing vessels that carry mail under contract by Royal Mail. Any vessel designated as RMS has the right to both fly the pennant of the Royal Mail when sailing and to include the Royal Mail "crown" logo with any identifying device and/or design for the ship.
It was used by many shipping lines, but is often associated in particular with the Cunard Line, Royal Mail Lines and Union-Castle Line, which held a number of high-profile mail contracts, and which traditionally prefixed the names of many of their ships with the initials "RMS".
While some lines in the past, particularly the Royal Mail Lines, called all their ships RMS, technically a ship would use the prefix only while contracted to carry mail, and would revert at other times to a standard designation such as "SS".
http://en.wikipedia.org/wiki/Royal_Mail_Ship