Return encoded Page Title outside of a loop

Here’s the answer:
Load wp_get_document_title(); into a variable.
Use ‘rawurlencode’ on the variable.
Also, apparently one can use a ” , ” to join to strings and not just ” . “

global $wp;
$url = home_url( $wp->request );
$page_title = wp_get_document_title();
?>
<?php
echo '<p class="side-bar-buttons"><i class="fa fa-envelope" aria-hidden="true"></i> ';
echo '<a href=mailto:?subject=" , rawurlencode($page_title);
echo "&body=' . $url;
echo '>Email This Page</a></p>';
?>```