No good at all. The opto's phototransistor is only rated for max. 35VDC (or 6V if reverse polarity), so it will fail as soon as mains is applied.
Pqass has already given good advice
For the TRIAC, yes, you need a box, just to avoid exposed mains terminals, but the heatsink doesn't have to be (and shouldn't be) live. Either use an isolated heatsink mounting kit for the TRIAC, or (easier) get a different one in an isolated package. If the heatsink is accessible it must be grounded for safety.