Unable to override pluggable function wp_mail

I think this line:

namespace MailDemo;

is the reason for you problems.

You define your custom wp_mail() function within this namespace, so it looks like you’re trying to override the function:

\MailDemo\wp_mail() 

but not the pluggable function:

\wp_mail()

Try to remove the namespace setup and see what happens.

Another way around this would be to include the override code part from a file, for example:

require_once plugin_dir_path( __FILE__ ) . 'override_wp_mail.php';

to have it in the global scope for the WordPress core.