To extend upon the Ulrich Schwarzs answer, providing a solution that should also work for "special" kinds of environment variables, I use awk with ENVIRON (answer given by dave_thompson_085):
$ echo 'Hello $USER $UNDEFINED_VARIABLE' | envsubst "$(awk 'BEGIN{for(e in ENVIRON)print "$"e}' | awk '{ printf("%s ", $0) }')"
Hello <user> $UNDEFINED_VARIABLE
In script:
environment_variables_single_line="$(awk 'BEGIN{for(e in ENVIRON)print "$"e}' | awk '{ printf("%s ", $0) }')"
envsubst "${environment_variables_in_single_line}" < ${source_file} > ${target_file}