How do I place a function in a standalone page?

If you’re just going to output your own data, there’s no reason to wait for the main query to run. Hook parse_request and check if your page was requested and run your code there.

function wpd_maybe_output_feed( $request ){
    if( isset( $request->query_vars['pagename'] )
        && 'gmailrss' == $request->query_vars['pagename'] ){
            header('Content-Type:text/xml; charset=UTF-8');
            echo checkGmail("gmail", "password");
            die;
    }
    return $request;
}
add_action( 'parse_request', 'wpd_maybe_output_feed' );