Emails via two different Postmark streams based on the email subject

/* Emails via two different Postmark streams based on the email subject * * Original doc: https://wpmailsmtp.com/docs/how-to-set-up-the-postmark-mailer-in-wp-mail-smtp/ */ // Conditionally set a Postmark mailer message stream in WP Mail SMTP add_filter( ‘wp_mail_smtp_providers_mailer_get_body’, function ( $body, $mailer ) { if (…Continue reading

Using an Office 365 GCC or DoD email address

/* 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 );…Continue reading

Hide the Email Test Menu Item in Settings

/* Hide the Email Test Menu Item in Settings * * Original doc: https://wpmailsmtp.com/docs/hiding-the-email-test-menu-item-in-settings/ */ add_filter( ‘wp_mail_smtp_admin_get_pages’, function ( $pages ) { unset( $pages[ ‘test’ ] ); return $pages; }, PHP_INT_MAX );Continue reading

Send Site Notifications to a BCC Address

/* Send Site Notifications to a BCC Address * * Original doc: https://wpmailsmtp.com/docs/sending-site-notifications-to-a-bcc-address/ */ function wpms_add_bcc_email_address( $args ) { $bcc_address = ‘bcc: [email protected]’; if ( ! empty( $args[ ‘headers’ ] ) ) { if ( ! is_array( $args[ ‘headers’ ]…Continue reading

Fix the InvalidInternetMessageHeader Error in Outlook

/* Fix the InvalidInternetMessageHeader Error in Outlook * * Original doc: https://wpmailsmtp.com/docs/fixing-the-invalidinternetmessageheader-error-in-outlook/ */ function wp_mail_smtp_modify_header( $body, $mailer ) { if ( ‘outlook’ === $mailer ) { $headers = $body[ ‘message’ ][ ‘internetMessageHeaders’ ]; foreach( $headers as $key => $header )…Continue reading

Set a Custom Reply-To Email

/* Set a Custom Reply-To Email * * Original doc: https://wpmailsmtp.com/docs/setting-a-custom-reply-to-email/ */ function wp_mail_smtp_dev_reply_to( $args ) { $reply_to = ‘Reply-To: Pattie Paloma ‘; if ( ! empty( $args[ ‘headers’ ] ) ) { if ( ! is_array( $args[ ‘headers’ ]…Continue reading

Use Single Tenant With the Outlook Mailer

/* Use Single Tenant With the Outlook Mailer * * Original doc: https://wpmailsmtp.com/docs/using-single-tenant-with-the-outlook-mailer/ */ add_filter( ‘wp_mail_smtp_pro_providers_outlook_auth_authorize_url’, function ( $url ) { $tenant_id = ‘my_tenant_id’; return str_replace( ‘/common/’, “/{$tenant_id}/”, $url ); } ); add_filter( ‘wp_mail_smtp_pro_providers_outlook_auth_access_token_url’, function ( $url ) { $tenant_id…Continue reading

Set a Custom Email Header

/* Set a Custom Email Header * * Original doc: https://wpmailsmtp.com/docs/setting-a-custom-email-header/ */ function wpmsmtp_custom_mail_header( $args ) { if ( ! is_array( $args[ ‘headers’ ] ) ) { $args[ ‘headers’ ] = explode( “\n”, str_replace( “\r\n”, “\n”, $args[ ‘headers’ ] )…Continue reading