To override the wp_mail() function using the filter pre_wp_mail is the best and modern way to do so. Using this method will future-proof your override.
You can remove the HTTP header X-Frame-Options: SAMEORIGIN from WordPress by removing the send_frame_options_header function from the admin_init and login_init hooks.