I would do some sort of lap joint, where you notch out part of the vertical support and replace that notch with the end of your horizontal 2x4. What are your plans to prevent racking? I dont think screwing it to the wall studs is the best answer but it would be an easy fix. You could skin the sides in thin plywood and add diagonal braces in the rear: this would leave the rear open for plumbing.