php
<?php
/* Using an Office 365 GCC or DoD email address  
 * 
 * Original doc: https://wpmailsmtp.com/docs/how-to-set-up-the-outlook-mailer-in-wp-mail-smtp/
*/
function theme_prefix_enable_gcc_high_and_dod_compatibility( $country_code ) {
 
    add_filter( 'wp_mail_smtp_pro_providers_outlook_auth_authorize_url', function ( $url ) use ( $country_code ) {
        return str_replace( 'microsoftonline.com', 'microsoftonline.' . $country_code, $url );
    } );
 
    add_filter( 'wp_mail_smtp_pro_providers_outlook_auth_access_token_url', function ( $url ) use ( $country_code ) {
        return str_replace( 'microsoftonline.com', 'microsoftonline.' . $country_code, $url );
    } );
 
    add_filter( 'wp_mail_smtp_pro_providers_outlook_auth_resource_owner_details_url', function ( $url ) use ( $country_code ) {
        return str_replace( 'microsoft.com', 'microsoft.' . $country_code, $url );
    } );
 
	add_filter( 'wp_mail_smtp_pro_providers_outlook_auth_get_scopes', function ( $scopes ) use ( $country_code ) {
		return array_map( function ( $url ) use ( $country_code ) {
			return str_replace( 'microsoft.com', 'microsoft.' . $country_code, $url );
		}, $scopes );
	} );
 
	add_filter( 'wp_mail_smtp_pro_providers_outlook_mailer_api_url', function ( $url ) use ( $country_code ) {
		return str_replace( 'microsoft.com', 'microsoft.' . $country_code, $url );
	} );
}
 
// Define country code as first parameter.
// If using a different a different country, replace 'us' with your 2 letter country code.
// To find your country code, please visit: https://www.iban.com/country-codes
theme_prefix_enable_gcc_high_and_dod_compatibility( 'us' );