How to keep variable `$post` to using in another file

$post isn’t set in an admin-ajax.php request because you’re not querying for any post or inside a loop. In your script that sends the ajax request you’ll need to send the post ID and retrieve a post object in the callback:

function ajax_cart_send_mail(){
    $post = get_post( $_POST['post_id'] );

    $id = $post->ID;
    $name = $post->post_title;
}
add_action('wp_ajax_ajax_cart_send_mail','ajax_cart_send_mail');
add_action('wp_ajax_nopriv_ajax_cart_send_mail','ajax_cart_send_mail');