generate_qr_code(); $this->app_connected = get_option( 'post_smtp_mobile_app_connection' ); } } } /** * Enqueue scripts * * @since 2.7.0 * @version 1.0.0 */ public function admin_enqueue() { wp_enqueue_script( 'post-smtp-mobile', POST_SMTP_URL . '/Postman/Mobile/assets/js/admin.js', array( 'jquery' ), POST_SMTP_VER ); wp_enqueue_style( 'post-smtp-mobile', POST_SMTP_URL . '/Postman/Mobile/assets/css/admin.css', array(), POST_SMTP_VER ); } /** * Add menu * * @since 2.7.0 * @version 1.0.0 */ public function add_menu() { if( postman_is_bfcm() ) { $menu_text = sprintf( '%s', __( 'Mobile App', 'post-smtp' ) ); } else { $menu_text = sprintf( '%s%s', __( 'Mobile App', 'post-smtp' ), __( 'New', 'post-smtp' ) ); } add_submenu_page( PostmanViewController::POSTMAN_MENU_SLUG, __( 'Mobile Application', 'post-smtp' ), $menu_text, 'manage_options', admin_url( 'admin.php?page=postman/configuration#mobile-app' ), '', 3 ); } /** * Add tab * * @since 2.7.0 * @version 1.0.0 */ public function tabs( $tabs ) { $tabs['mobile-app'] = sprintf( ' %s', __( 'Mobile App', 'post-smtp' ) ); return $tabs; } /** * Generate QR code * * @since 2.7.0 * @version 1.0.0 */ public function generate_qr_code() { if ( !class_exists('QRcode') ) { include_once 'includes/phpqrcode/qrlib.php'; } $nonce = get_transient( 'post_smtp_auth_nonce' ); $authkey = $nonce ? $nonce : $this->generate_auth_key(); $site_title = get_bloginfo( 'name' ); set_transient( 'post_smtp_auth_nonce', $authkey, 1800 ); $endpoint = site_url( "?authkey={$authkey}&site_title={$site_title}" ); ob_start(); QRcode::png( urlencode_deep( $endpoint ) ); $result_qr_content_in_png = ob_get_contents(); ob_end_clean(); // PHPQRCode change the content-type into image/png... we change it again into html header("Content-type: text/html"); $this->qr_code = base64_encode( $result_qr_content_in_png ); } /** * Generate auth key * * @since 2.7.0 * @version 1.0.0 */ private function generate_auth_key() { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; $chars .= '!@#$%^*()'; $chars .= '-_ []{}<>~`+,.;:/|'; $pass = array(); //remember to declare $pass as an array $alphaLength = strlen( $chars ) - 1; //put the length -1 in cache for ( $i = 0; $i < 32; $i++ ) { $n = rand( 0, $alphaLength ); $pass[] = $chars[$n]; } return implode( $pass ); //turn the array into a string } /** * Section * * @since 2.7.0 * @version 1.0.0 */ public function section() { $nonce = wp_create_nonce( 'ps-regenerate-qrcode-nonce' ); //Incompatible server if( function_exists( 'ImageCreate' ) ): ?>

Download Post SMTP Mobile Application

  1. Open Post SMTP mobile app 📱 on your android or iOS device.
  2. Tap on Scan QR Code button to link your mobile device with Post SMTP plugin.
  3. Point your mobile device to this screen to capture the QR Code.

And you are done👍.

Want more details? Check out our complete guide Post SMTP Plugin with Mobile App

app_connected ) { echo ''; ?>
">
Connected Device: "; $nonce = wp_create_nonce( 'ps-disconnect-app-nonce' ); foreach( $this->app_connected as $device ) { $url = admin_url( "admin.php?action=post_smtp_disconnect_app&auth_token={$device['fcm_token']}&ps_disconnect_app_nonce={$nonce}" ); $checked = $device['enable_notification'] == 1 ? 'checked="checked"' : ''; echo esc_html( $device['device'] ) . "Disconnect"; echo '
'; echo sprintf( '', __( 'Send failed email notification' ), $device['fcm_token'], $checked ); } } ?>

%s', __( 'Your server does not have GD Library Installed/ Enabled, talk to your host provider to enable to enjoy Post SMTP Mobile Application', 'post-smtp' ), esc_url( 'https://www.php.net/manual/en/image.installation.php' ), __( 'learn more.', 'post-smtp' ) ) ?>
$device ) { if( in_array( $device['fcm_token'], $devices ) ) { $connected_devices[$key]['enable_notification'] = 1; } else { $connected_devices[$key]['enable_notification'] = 0; } } } update_option( 'post_smtp_mobile_app_connection', $connected_devices ); return $input; } /** * Disconnects the mobile application :( * * @since 2.7.0 * @version 1.0.0 */ public function disconnect_app() { if( !isset( $_GET['ps_disconnect_app_nonce'] ) || !wp_verify_nonce( $_GET['ps_disconnect_app_nonce'], 'ps-disconnect-app-nonce' ) ) { die( 'Security Check' ); } if( isset( $_GET['action'] ) && $_GET['action'] == 'post_smtp_disconnect_app' ) { $connected_devices = get_option( 'post_smtp_mobile_app_connection' ); $auth_token = $_GET['auth_token']; $server_url = get_option( 'post_smtp_server_url' ); if( $connected_devices && isset( $connected_devices[$auth_token] ) ) { $device = $connected_devices[$auth_token]; $auth_key = $device['auth_key']; $response = wp_remote_post( "{$server_url}/disconnect-app", array( 'method' => 'PUT', 'headers' => array( 'Content-Type' => 'application/json', 'Auth-Key' => $auth_key, 'FCM-Token' => $auth_token ) ) ); $response_code = wp_remote_retrieve_response_code( $response ); if( $response_code == 200 ) { delete_option( 'post_smtp_mobile_app_connection' ); delete_option( 'post_smtp_server_url' ); } } wp_redirect( admin_url( 'admin.php?page=postman/configuration#mobile-app' ) ); } } /** * Dismiss App Notice | Action Call-back * * @since 2.7.1 * @version 1.0.0 */ public function dismiss_app_notice() { if( isset( $_GET['action'] ) && $_GET['action'] === 'ps_dimiss_app_notice' ) { update_option( 'ps_dismissed_mobile_notice', 1 ); wp_redirect( admin_url( 'admin.php?page=postman' ) ); } } /** * Regenerates QR Code | Action Call-back * * @since 2.8.2 * @version 1.0.0 */ public function regenerate_qrcode() { if( ! isset( $_GET['_psnonce'] ) || ! wp_verify_nonce( $_GET['_psnonce'], 'ps-regenerate-qrcode-nonce' ) ) { die( 'Security Check' ); } if( isset( $_GET['action'] ) && $_GET['action'] === 'regenerate-qrcode' ) { delete_transient( 'post_smtp_auth_nonce' ); wp_redirect( admin_url( 'admin.php?page=postman/configuration#mobile-app' ) ); } } /** * Remove Device With Incomplete Information * * @since 2.8.10 * @version 1.0.0 */ public function remove_device() { if( !isset( $_GET['page'] ) || ( isset( $_GET['page'] ) && $_GET['page'] !== 'postman/configuration' ) ) { $device = get_option( 'post_smtp_mobile_app_connection' ); $device = $device ? reset( $device ) : $device; if( $device && !isset( $device['auth_key'] ) || $device && empty( $device['auth_key'] ) ) { delete_option( 'post_smtp_mobile_app_connection' ); delete_option( 'post_smtp_server_url' ); delete_transient( 'post_smtp_auth_nonce' ); return; } return; } } } Post_SMTP_Mobile::get_instance();