bash mail subject variable

C++
subj="hello from $(hostname -s) $(date)" 
echo "data" | mail -s $subj mail@mail

Source

Also in C++: