Basically, this is an extension of what happens when we listen to music. This is a hard lesson to absorb but paying attention to the frequency (high, medium, low) of your vowel sounds can help you work your magic on the reader's subconscious. You can also invoke that through the use of "high, medium, or low" alliteration and/or imagery. More on that later.
For now, let's look at this from a purely musical angle. If you have the know-how and an instrument, now's the time to use 'em. Otherwise, here's a simple little program that will work fine for what I'm trying to illustrate.
Once you've done that, look at the placement of those notes. You'll probably notice that a melancholy tune starts low or high, goes higher, then ends lower. That last part creates the descending emotional feeling that can sound sad, or bittersweet, melancholy, etc. On the other hand, an uplifting tune might be all over the place but probably ends on an ascending note, and almost certainly has more high frequency notes throughout.
The $50,000 point: it's entirely possible to replicate this with word choice. It's not easy, but it's what distinguishes lyrical from tone-deaf poetry.
Now, you may be thinking that if there are only 3 basic vowel frequencies (high = E and I, middle = A and Y, low = U and O), how can you get that kind of range? Well, first thing’s first. If you want to write an uplifting poem, basic limitations of language and spelling won’t let you use only words that have E and I vowel sounds. So don’t go nuts. You’re just going for a simple majority here. Also, you don’t have to restrict yourself to vowel frequencies. Mix in images whose denotation and/or connotation furthers what you’re going for.
So in practical terms: if you want an ominous poem, back up your lower frequency vowel sounds with some ominous imagery. Or maybe you use uplifting imagery but low vowel sounds to create a trapped feeling, a tension between the two. If you want a derisive and slightly hopeful poem, maybe you use ominous connotations but higher vowel sounds (or vice versa).
On the other hand, an uplifting poem with high frequency vowel sounds AND uplifting imagery might seem a bit cheesy—meaning, it doesn’t have enough grit in it, so throw in some lower frequency vowel sounds and less cheery imagery. And it's also worth pointing out that a poem with high frequency vowel sounds AND "happy" imagery can't really invoke a negative feeling, EXCEPT the feeling that it's cliche and/or cheesy, and two dimensional.
OK, now consider alliteration. Obviously, a hard K sound invokes a different feeling (all else being equal) than a smooth S sound. So if you want to invoke a soothing, steady feeling, you’re probably not going to use lots of hard alliteration (hard K, hard G, etc). On the other hand, you might use lots of hard alliteration if you want to build suspense, make things seem a little more chaotic.
Think of all these different factors (the psychological impact/connotation of your word choice, vowel sounds, and alliteration) as ingredients. How you mix them is based entirely on your lyrical aesthetic.
As with anything, there are plenty of exceptions to the rules. In fact, you might do exactly the opposite of everything I’ve said and still get from A to B with good results. Either way, though, developing an ear for this will greatly help your writing (whether you’re talking about poetry or prose) and I’d wager that on a subconscious level, this is exactly what all great writers and songwriters are doing.