Q:

Bash: Assign output of command group to variable

While it is possible to assign the output of a shell command to a variable like so:
list=$(ls -la)

It seems that I cannot assign the output of a command group to a variable. This here seems not to work:
output=${ echo "Peter"; echo "Pan"; }

But: Piping the output of a command group [1] is possible:
{
 echo "To: $MAILTO"
 echo "From: $FROM"
 echo "Subject: $SUBJ"
 echo
 echo "Please check $HOSTNAME"
} | ssmtp $MAILTO

Why can't I assign the output of the command group to a variable?

[1] Command group:  { ... } | ...
See: https://ss64.com/bash/syntax-brackets.html

A:

This doesn't work because you are using curly braces:
$ output=${ echo "Peter"; echo "Pan"; }
bash: ${ echo "Peter"; echo "Pan"; }: bad substitution

Inside curly braces, ${...}, bash expects the name of a variable.  
To capture the output of a command, use parens:
$ output=$( echo "Peter"; echo "Pan"; )
$ echo "$output"
Peter
Pan

