This is an excellent television, but Samsung scrimped a bit too much on the connections available. While many flatscreens offer digital optical out and a complement of video and network connections, this television has not even enough to connect to a home theatre system and allow you to listen to the TV sound through your speakers. It's also very poorly documented.
The UE40D5003 does not appear to have any SPDIF optical out. This despite some Samsung Support claims that it does, so be wary. It has two HDMI sockets, a SCART socket, A CI card slot (does anyone use this?) a USB slot and a 3.5mm headphone jack.
It should be possible to connect a "3.5mm headphone to RCA" extension lead to send audio to any home theatre system. Samsung Support indicates this will permanently mute the television speakers and I can confirm this is so. However, the supplied printed manual is unclear, stating "Sound function may be restricted when connecting headphones to the TV" (*May* be? I take it they do not understand what "may" means in English. It's like saying "We are not sure what will happen when you plug in headphones. Maybe sound - maybe no sound. Let us know, OK?")
The manual and documentation are also unclear whether any of the other connections could be used for audio, such as the second HDMI or the SCART, as both - in theory - are capable of carrying sound. *see update in comments*
It appears Samsung, in its desire to decontent this TV and reduce costs, has hampered its connectivity and use. If I just want to watch the news, TV sound alone is fine and simple. If I want to enjoy a DVD, then a Home Theatre sound is preferred. It is not one or the other, Samsung - it is both.
My suggestion for Home Theatre sound is to use a headphone cable extension (to RCA) lead. This does require the sound system to be on simply to watch TV, but this can be bypassed by unplugging the headphone jack if so required. A bit of a kludge, but easy enough. Shame on Samsung for hamstringing an otherwise excellent product with their cheapness.
Also be aware that the sockets point straight back, so you will need a wall mount with enough depth to allow SCART (or whatever you use) to connect. There is also a "flip" on the back panel just above the mount for the stand. This doesn't appear to have any purpose, but it does interfere with many VESA-standard wall mounts and prevents the TV side of the mount from sitting flat. You can add spacers, which you will probably need anyway since the cable access is so restrictive.