array( 'type' => array(), 'id' => array(), 'name' => array(), 'value' => array(), 'class' => array(), 'placeholder' => array(), 'size' => array(), 'checked' => array(), 'required' => array(), 'data-error' => array(), 'readonly' => array(), 'disabled' => array() ), 'div' => array( 'class' => array() ), 'label' => array( 'class' => array() ), 'span' => array( 'class' => array() ), 'b' => array(), 'a' => array( 'href' => array(), 'target' => array(), 'class' => array(), 'id' => array() ), 'p' => array(), 'h3' => array(), 'select' => array( 'name' => array() ), 'option' => array( 'value' => array(), 'selected' => array() ), 'hr' => array() ); private $socket_sequence = array(); /** * Constructor for the class * * @since 2.7.0 * @version 1.0.0 */ public function __construct() { $this->socket_sequence = array( 'gmail_api', 'resend_api', 'sendinblue_api', 'mailtrap_api', 'sendgrid_api', 'mailgun_api', 'elasticemail_api', 'mandrill_api', 'postmark_api', 'sparkpost_api', 'mailjet_api', 'smtp2go_api', 'sendpulse_api', 'mailersend_api', 'emailit_api', 'maileroo_api', 'sweego_api' ); if( !is_plugin_active( 'post-smtp-pro/post-smtp-pro.php' ) ) { $this->socket_sequence[] = 'office365_api'; $this->socket_sequence[] = 'aws_ses_api'; $this->socket_sequence[] = 'zohomail_api'; } $this->socket_sequence[] = 'smtp'; $this->socket_sequence[] = 'default'; add_filter( 'post_smtp_legacy_wizard', '__return_false' ); add_action( 'post_smtp_new_wizard', array( $this, 'load_wizard' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_action( 'wp_ajax_ps-save-wizard', array( $this, 'save_wizard' ) ); add_action( 'wp_ajax_update_post_smtp_pro_option', array( $this, 'update_post_smtp_pro_option_callback' ) ); add_action( 'wp_ajax_update_post_smtp_pro_option_office365', array( $this, 'update_post_smtp_pro_option_office365_callback' ) ); add_action( 'admin_action_zoho_auth_request', array( $this, 'auth_zoho' ) ); add_action( 'admin_post_remove_oauth_action', array( $this, 'post_smtp_remove_oauth_action' ) ); add_action( 'admin_init', array( $this, 'handle_gmail_oauth_redirect' ) ); add_action( 'admin_init', array( $this, 'handle_office365_oauth_redirect' ) ); add_action( 'admin_post_remove_365_oauth_action', array( $this, 'post_smtp_remove_365_oauth_action' ) ); if( isset( $_GET['wizard'] ) && $_GET['wizard'] == 'legacy' ) { add_filter( 'post_smtp_legacy_wizard', '__return_true' ); } $this->options_array = get_option( PostmanOptions::POSTMAN_OPTIONS ); } /** * Load the wizard | Action Callback * * @since 2.7.0 * @version 1.0.0 */ public function load_wizard() { $transports = PostmanTransportRegistry::getInstance()->getTransports(); //Not for wizard $settings_registry = new PostmanSettingsRegistry(); $this->options = PostmanOptions::getInstance(); $is_active = ( isset( $_GET['step'] ) && $_GET['step'] == 2 ) ? 'ps-active-nav' : 'ps-in-active-nav'; $in_active = ( isset( $_GET['step'] ) && $_GET['step'] != 1 ) ? '' : 'ps-active-nav'; $selected_tansport = $this->options->getTransportType(); $socket = isset( $_GET['socket'] ) ? "{$_GET['socket']}-outer" : ''; // Add popup trigger file require_once POST_SMTP_PATH. '/Postman/Popup/popup.php'; ?>

socket_sequence ), $transports ); foreach( $transports as $key => $transport ) { $urls = array( 'default' => POST_SMTP_URL . '/Postman/Wizard/assets/images/smtp.png', 'smtp' => POST_SMTP_URL . '/Postman/Wizard/assets/images/smtp.png', 'gmail_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/gmail.png', 'mandrill_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/mandrill.png', 'sendgrid_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/sendgrid.png', 'mailersend_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/mailersend.png', 'mailgun_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/mailgun.png', 'sendinblue_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/brevo.png', 'mailtrap_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/mailtrap.png', 'postmark_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/postmark.png', 'sparkpost_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/sparkpost.png', 'mailjet_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/mailjet.png', 'sendpulse_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/sendpulse.png', 'smtp2go_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/smtp2go.png', 'office365_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/ms365.png', 'elasticemail_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/elasticemail.png', 'aws_ses_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/amazon.png', 'zohomail_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/zoho.png', 'resend_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/resend.png', 'emailit_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/emailit.png', 'maileroo_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/maileroo.png', 'sweego_api' => POST_SMTP_URL . '/Postman/Wizard/assets/images/sweego.png' ); $url = ''; $checked = ''; $slug = ''; $transport_name = ''; $is_pro = ''; $product_url = ''; if( is_object( $transport ) ) { $url = isset( $urls[$transport->getSlug()] ) ? $urls[$transport->getSlug()] : $transport->getLogoURL(); $this->sockets[$transport->getSlug()] = $transport->getName(); if( isset( $_GET['socket'] ) && !empty( sanitize_text_field( $_GET['socket'] ) ) && $transport->getSlug() == sanitize_text_field( $_GET['socket'] ) ) { $checked = 'checked'; } elseif( $transport->getSlug() == $this->options->getTransportType() && !is_plugin_active( 'post-smtp-pro/post-smtp-pro.php' ) ) { $checked = 'checked'; } $slug = $transport->getSlug(); $transport_name = $transport->getName(); } else { $transport_slug = $key; if( $transport_slug == 'office365_api' ) { $url = POST_SMTP_URL . '/Postman/Wizard/assets/images/ms365.png'; $slug = $transport_slug; $transport_name = 'Microsoft 365'; $is_pro = 'ps-pro-extension'; $product_url = postman_is_bfcm() ? 'https://postmansmtp.com/cyber-monday-sale?utm_source=plugin&utm_medium=section_name&utm_campaign=BFCM&utm_id=BFCM_2024' : 'https://postmansmtp.com/pricing/?utm_source=plugin&utm_medium=wizard_microsoft&utm_campaign=plugin'; } if( $transport_slug == 'zohomail_api' ) { $url = POST_SMTP_URL . '/Postman/Wizard/assets/images/zoho.png'; $slug = $transport_slug; $transport_name = 'Zoho'; $is_pro = 'ps-pro-extension'; $product_url = postman_is_bfcm() ? 'https://postmansmtp.com/cyber-monday-sale?utm_source=plugin&utm_medium=section_name&utm_campaign=BFCM&utm_id=BFCM_2024' : 'https://postmansmtp.com/pricing/?utm_source=plugin&utm_medium=wizard_zoho&utm_campaign=plugin'; } if( !class_exists( 'Post_Smtp_Amazon_Ses' ) && $transport_slug == 'aws_ses_api' ) { $url = POST_SMTP_URL . '/Postman/Wizard/assets/images/amazon.png'; $slug = $transport_slug; $transport_name = 'Amazon SES'; $is_pro = 'ps-pro-extension'; $product_url = postman_is_bfcm() ? 'https://postmansmtp.com/cyber-monday-sale?utm_source=plugin&utm_medium=section_name&utm_campaign=BFCM&utm_id=BFCM_2024' : 'https://postmansmtp.com/pricing/?utm_source=plugin&utm_medium=wizard_amazonses&utm_campaign=plugin'; } } if( $row >= 4 ) { $row = 0; ?>
> PRO

%3$s', __( 'Need help in choosing one?', 'post-smtp' ), esc_url( admin_url( 'admin.php?page=postman-contact' ) ), __( 'Check out our Mailer Guide.', 'post-smtp' ) ); ?>

Back sockets ) ) { $this->render_name_email_settings(); foreach( $this->sockets as $key => $title ) { $active_socket = ( isset( $_GET['socket'] ) && $_GET['socket'] == $key ) ? 'style="display: block;"' : ''; ?>
>

render_socket_settings( $key ); ?>

.

%3$s', __( 'We value your opinion on your experience with Post SMTP and would appreciate your feedback. ', 'post-smtp' ), esc_url( 'https://wordpress.org/support/plugin/post-smtp/reviews/#new-post' ), __( 'Leave a review here.', 'post-smtp' ) ) ?>

__( 'Select a socket type to continue.', 'post-smtp' ), 'Step2E2' => __( 'Please enter From Email.', 'post-smtp' ), 'Step2E3' => __( 'Please try again, something went wrong.', 'post-smtp' ), 'Step3E4' => __( 'Please enter recipient email address.', 'post-smtp' ), 'finish' => __( 'Finish', 'post-smtp' ), 'adminURL' => admin_url(), 'connectivityTestMsg' => sprintf( '%1$s %2$s %4$s %5$s', '', __( 'Take the', 'post-smtp' ), esc_url( admin_url( 'admin.php?page=postman/port_test' ) ), __( 'connectivity test', 'post-smtp' ), __( 'of your site to get more information about this failure.', 'post-smtp' ) ), // Add the nonce for pro option AJAX 'pro_option_nonce' => wp_create_nonce('update_post_smtp_pro_option'), ); if( class_exists( 'Post_Smtp_Office365' ) ) { //Office 365 URL Params | State $state = get_transient( Post_Smtp_Office365::STATE ); if ( $state === false ) { $state = bin2hex( random_bytes( 32 / 2 ) ); set_transient( Post_Smtp_Office365::STATE, $state, 5 * MINUTE_IN_SECONDS ); } $localized['office365State'] = $state; } $gmail_icon_url = POST_SMTP_URL . '/Postman/Wizard/assets/images/gmail.png'; $localized['gmail_icon'] = $gmail_icon_url; $localized['tenantId'] = apply_filters( 'post_smtp_office365_tenant_id', 'common' ); $office365_icon_url = POST_SMTP_URL . '/Postman/Wizard/assets/images/ms365.png'; $localized['office365_icon'] = $office365_icon_url; wp_enqueue_style( 'post-smtp-wizard', POST_SMTP_URL . '/Postman/Wizard/assets/css/wizard.css', array(), POST_SMTP_VER ); wp_enqueue_script( 'post-smtp-wizard', POST_SMTP_URL . '/Postman/Wizard/assets/js/wizard.js', array( 'jquery' ), POST_SMTP_VER ); wp_localize_script( 'post-smtp-wizard', 'PostSMTPWizard', $localized ); } /** * Render Name and Email Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_name_email_settings() { $from_name = null !== $this->options->getMessageSenderName() ? esc_attr( $this->options->getMessageSenderName() ) : ''; $from_email = null !== $this->options->getMessageSenderEmail() ? esc_attr( $this->options->getMessageSenderEmail() ) : ''; $from_name_enforced = $this->options->isPluginSenderNameEnforced() ? 'checked' : ''; $from_email_enforced = $this->options->isPluginSenderEmailEnforced() ? 'checked' : ''; $html = '

From Address

'. sprintf( '%1$s', esc_html__( 'It is important to indicate the origin (email and name) of a message for the receiver. The From Address provides these details.', 'post-smtp' ) ) .'

'. sprintf( '%1$s', esc_html__( 'You may edit the following field if you do not wish to use default settings.', 'post-smtp' ) ) .'

'.__( 'The email address that emails are sent from.', 'post-smtp' ).'
'.__( 'Please note that other plugins may override this field, to prevent this use the setting below.', 'post-smtp' ).'
'. sprintf( '%1$s %2$s %3$s %4$s %5$s %6$s', __( 'Check this to prevent changes on the', 'post-smtp' ), __( 'From Email', 'post-smtp' ), __( 'field by other', 'post-smtp' ), __( 'Plugins', 'post-smtp' ), __( 'and', 'post-smtp' ), __( 'Themes', 'post-smtp' ) ). '
'.__( 'The name that emails are sent from.', 'post-smtp' ).'
'. sprintf( '%1$s %2$s %3$s %4$s %5$s %6$s', __( 'Check this to prevent changes on the', 'post-smtp' ), __( 'From Name', 'post-smtp' ), __( 'field by other', 'post-smtp' ), __( 'Plugins', 'post-smtp' ), __( 'and', 'post-smtp' ), __( 'Themes', 'post-smtp' ) ). '
'; echo wp_kses( $html, $this->allowed_tags ); } /** * Render Socket Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_socket_settings( $socket ) { switch ( $socket ) { case 'default': echo wp_kses( $this->render_default_settings(), $this->allowed_tags ); break; case 'smtp': echo wp_kses( $this->render_smtp_settings(), $this->allowed_tags ); break; case 'gmail_api': echo wp_kses( $this->render_gmail_settings(), $this->allowed_tags ); break; case 'mandrill_api': echo wp_kses( $this->render_mandrill_settings(), $this->allowed_tags ); break; case 'emailit_api': echo wp_kses( $this->render_emailit_settings(), $this->allowed_tags ); break; case 'maileroo_api': echo wp_kses( $this->render_maileroo_settings(), $this->allowed_tags ); break; case 'sweego_api': echo wp_kses( $this->render_sweego_settings(), $this->allowed_tags ); break; case 'sendgrid_api': echo wp_kses( $this->render_sendgrid_settings(), $this->allowed_tags ); break; case 'mailersend_api': echo wp_kses( $this->render_mailersend_settings(), $this->allowed_tags ); break; case 'mailgun_api': echo wp_kses( $this->render_mailgun_settings(), $this->allowed_tags ); break; case 'sendinblue_api': echo wp_kses( $this->render_brevo_settings(), $this->allowed_tags ); break; case 'mailtrap_api': echo wp_kses( $this->render_mailtrap_settings(), $this->allowed_tags ); break; case 'resend_api': echo wp_kses( $this->render_resend_settings(), $this->allowed_tags ); break; case 'postmark_api': echo wp_kses( $this->render_postmark_settings(), $this->allowed_tags ); break; case 'sparkpost_api': echo wp_kses( $this->render_sparkpost_settings(), $this->allowed_tags ); break; case 'mailjet_api': echo wp_kses( $this->render_mailjet_settings(), $this->allowed_tags ); break; case 'sendpulse_api': echo wp_kses( $this->render_sendpulse_settings(), $this->allowed_tags ); break; case 'elasticemail_api': echo wp_kses( $this->render_elasticemail_settings(), $this->allowed_tags ); break; case 'aws_ses_api'; echo wp_kses( $this->render_amazonses_settings(), $this->allowed_tags ); break; case 'office365_api'; echo wp_kses( $this->render_office365_settings(), $this->allowed_tags ); break; case 'zohomail_api'; echo wp_kses( $this->render_zoho_settings(), $this->allowed_tags ); break; case 'smtp2go_api': echo wp_kses( $this->render_smtp2go_settings(), $this->allowed_tags ); break; } } /** * Render default Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_default_settings() { $html = ''; return $html; } /** * Render SMTP Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_smtp_settings() { $hostname = null !== $this->options->getHostname() ? esc_attr ( $this->options->getHostname() ) : ''; $port = null !== $this->options->getPort() ? esc_attr ( $this->options->getPort() ) : ''; $username = null !== $this->options->getUsername() ? esc_attr ( $this->options->getUsername() ) : ''; $password = null !== $this->options->getPassword() ? esc_attr ( $this->options->getPassword() ) : ''; $html = '

' . esc_html__( 'You can set up any SMTP of your choice, but it is important to remember that custom SMTP may not have adequate security.', 'post-smtp' ) . '

'; $html .= '

' . esc_html__( 'Kindly check our ', 'post-smtp' ) . '' . esc_html__( 'SMTP documentation', 'post-smtp' ) . '' . esc_html__( ' before implementation.', 'post-smtp' ) . '

'; $html .= '
'.__( 'Outgoing Mail Server Hostname', 'post-smtp' ).'
'; $html .= '
'.__( 'Outgoing Mail Server Port', 'post-smtp' ).'
'; $html .= '
'.__( 'The Username is usually the same as the Envelope-From Email Address.', 'post-smtp' ).'
'; $html .= '
'.__( 'Password or App Password.', 'post-smtp' ).'
'; return $html; } /** * Render Gmail API Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_gmail_settings() { // Get the Client ID and Client Secret from options $client_id = ! is_null( $this->options->getClientId() ) ? esc_attr( $this->options->getClientId() ) : ''; $client_secret = ! is_null( $this->options->getClientSecret() ) ? esc_attr( $this->options->getClientSecret() ) : ''; // Check if the 'success' parameter exists in URL $required = isset( $_GET['success'] ) && $_GET['success'] == 1 ? '' : 'required'; // Retrieve options for premium features and extensions $post_smtp_pro_options = get_option( 'post_smtp_pro', [] ); $postman_auth_token = get_option( 'postman_auth_token' ); $bonus_extensions = isset( $post_smtp_pro_options['extensions'] ) ? $post_smtp_pro_options['extensions'] : []; $gmail_oneclick_enabled = in_array( 'gmail-oneclick', $bonus_extensions ); $auth_url = get_option( 'post_smtp_gmail_auth_url' ); // Setup classes and attributes for form visibility $hidden_class = $gmail_oneclick_enabled ? 'ps-hidden' : ''; $client_id_required = $gmail_oneclick_enabled ? '' : 'required'; $client_secret_required = $gmail_oneclick_enabled ? '' : 'required'; $one_click_class = 'ps-enable-gmail-one-click'; $url = POST_SMTP_URL . '/Postman/Wizard/assets/images/wizard-google.png'; $transport_name = __( '1-Click Google Mailer Setup?', 'post-smtp' ); $product_url = postman_is_bfcm() ? 'https://postmansmtp.com/cyber-monday-sale?utm_source=plugin&utm_medium=section_name&utm_campaign=BFCM&utm_id=BFCM_2024' : 'https://postmansmtp.com/pricing/?utm_source=plugin&utm_medium=wizard_gmail_one_click&utm_campaign=plugin'; if ( isset( $_GET['success'] ) && $_GET['success'] == 1 ) { $client_id_required = ''; $client_secret_required = ''; } // Prepare data for JSON encoding $data = [ 'url' => $url, 'transport_name' => $transport_name, 'product_url' => $product_url ]; $json_data = htmlspecialchars( json_encode( $data ), ENT_QUOTES, 'UTF-8' ); // Begin HTML output $html = '

' . esc_html__( 'Post SMTP offers two ways to connect Gmail API with WordPress: One-Click Setup (fastest) and Manual (free).', 'post-smtp' ) . '

'; $html .= '
'; if ( post_smtp_has_pro() ) { $one_click = true; $html .= sprintf( '

%1$s

', __( 'One-Click Setup', 'post-smtp' ) ); } else { $html .= sprintf( '

%1$s %2$s

', __( 'One-Click Setup', 'post-smtp' ), __( 'PRO', 'post-smtp' ) ); $one_click = 'disabled'; $one_click_class .= ' disabled'; } $html .= __( '

Enable the option for a quick and easy way to connect with Google without the need of manually creating an app.

', 'post-smtp' ); // One-click switch control $html .= "

"; // Client ID and Secret inputs $html .= '

' . esc_html__( 'Manual Setup (FREE)', 'post-smtp' ) . '

' . esc_html__( 'The free Gmail mailer requires you to create an app manually to generate the Client ID and Client Secret.', 'post-smtp' ) . '

'; $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
' . __( 'Please copy this URL into the "Authorized redirect URL" field of your Gmail account settings.', 'post-smtp' ) . '
'; $html .= '

' . __( 'Authorization (Required)', 'post-smtp' ) . '

' . __( 'Before continuing, you\'ll need to allow this plugin to send emails using Gmail API.', 'post-smtp' ) . '

' . __( 'Connect to Gmail API', 'post-smtp' ) . ''; // Remove OAuth action button $html .= '
'; $html .= '
'; if ( post_smtp_has_pro() ) { if ( $postman_auth_token && isset( $postman_auth_token['user_email'] ) ) { $nonce = wp_create_nonce( 'remove_oauth_action' ); $action_url = esc_url( add_query_arg( [ '_wpnonce' => $nonce, 'action' => 'remove_oauth_action', ], admin_url( 'admin-post.php' ) ) ); if ( isset( $postman_auth_token['user_email'] ) ) { $html .= ' ' . sprintf( esc_html__('Connected with: %s', 'post-smtp'), esc_html( $postman_auth_token['user_email'] ) ) . ''; } $html .= ''; $html .= esc_html__( 'Remove Authorization', 'post-smtp' ); $html .= ''; }else { $html .= '

' . esc_html__( 'Authorization (Required)', 'post-smtp' ) . '

'; $html .= '

' . esc_html__( 'Before continuing, you\'ll need to allow this plugin to send emails using Gmail API.', 'post-smtp' ) . '

'; $html .= ''; $html .= ''; $html .= esc_html__( 'Sign in with Google', 'post-smtp' ); $html .= ''; $html .= "

By signing in with Google, you can send emails using different 'From' addresses. To do this, disable the 'Force From Email' setting and use your registered aliases as the 'From' address across your WordPress site.

Removing the OAuth connection will give you the ability to redo the OAuth connection or link to another Google account.

"; } } $html .= '
'; return $html; } /** * Render Emailit Settings */ public function render_emailit_settings() { $api_key = null !== $this->options->getEmailitApiKey() ? esc_attr ( $this->options->getEmailitApiKey() ) : ''; $html = sprintf( '

%2$s %3$s

', esc_url( 'https://emailit.com/' ), __( 'Emailit', 'post-smtp' ), __( 'is a transactional email provider. Enter your API Key and Endpoint below.', 'post-smtp' ) ); $html .= '
'; return $html; } /** * Render Emailit Settings */ public function render_sweego_settings() { $api_key = null !== $this->options->getSweegoApiKey() ? esc_attr ( $this->options->getSweegoApiKey() ) : ''; $html = sprintf( '

%1$s %3$s %4$s

', __( 'Integrating Sweego with your WordPress site. We recommend checking the', 'post-smtp' ), esc_url( 'https://postmansmtp.com/docs/mailers/how-to-setup-sweego-with-post-smtp/' ), __( 'documentation', 'post-smtp' ), __( 'for a successful integration.', 'post-smtp' ) ); $html .= '
'; return $html; } /** * Render Maileroo Settings */ public function render_maileroo_settings() { $api_key = null !== $this->options->getMailerooApiKey() ? esc_attr ( $this->options->getMailerooApiKey() ) : ''; $html = sprintf( '

%2$s %3$s

', esc_url( 'https://maileroo.com/' ), __( 'Maileroo', 'post-smtp' ), __( 'is a transactional email provider. Enter your API Key and Endpoint below.', 'post-smtp' ) ); $html .= '
'; return $html; } /** * Render Mandrill Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_mandrill_settings() { $api_key = null !== $this->options->getMandrillApiKey() ? esc_attr ( $this->options->getMandrillApiKey() ) : ''; $html = '

' . esc_html__( 'It is easy to integrate Mandrill mailer to your WordPress website. We recommend you to ', 'post-smtp' ) . '' . esc_html__( 'check the documentation', 'post-smtp' ) . '' . esc_html__( ' for a successful integration.', 'post-smtp' ) . '

'; $html .= '
'. /** * Translators: %1$s Text, %2$s URL, %3$s URL Text, %4$s Text, %5$s URL, %6$s URL Text */ '
' . esc_html__( 'You can find ', 'post-smtp' ) . '' . esc_html__( 'the API key', 'post-smtp' ) . '' . esc_html__( ' in your Mandrill account.', 'post-smtp' ) . '
' .'
'; return $html; } /** * Render SendGrid Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_sendgrid_settings() { $api_key = null !== $this->options->getSendGridApiKey() ? esc_attr ( $this->options->getSendGridApiKey() ) : ''; $selected_region = $this->options->getSendGridRegion() ? esc_attr( $this->options->getSendGridRegion() ) : 'AG'; $html = '

' . esc_html__( 'It is easy to integrate SendGrid mailer to your WordPress website. We recommend you to check the ', 'post-smtp' ) . '' . esc_html__( 'documentation', 'post-smtp' ) . '' . esc_html__( ' for a successful integration.', 'post-smtp' ) . '

'; $html .= '
' . esc_html__( 'You can find ', 'post-smtp' ) . '' . esc_html__( 'the API key above', 'post-smtp' ) . ' ' . esc_html__( 'in your SendGrid account.', 'post-smtp' ) . '
' . '
'; // Region dropdown. $html .= '
'; $html .= '
'; $html .= ''; $html .= '
'; return $html; } /** * Render MailerSend Settings * * @since 3.3.0 * @version 1.0.0 */ public function render_mailersend_settings() { $api_key = null !== $this->options->getMailerSendApiKey() ? esc_attr ( $this->options->getMailerSendApiKey() ) : ''; $html = '

' . esc_html__( 'It is easy to integrate MailerSend API mailer to your WordPress website. We recommend you to ', 'post-smtp' ) . '' . esc_html__( 'check the documentation', 'post-smtp' ) . '' . esc_html__( ' for a successful integration.', 'post-smtp' ) . '

'; $html .= '
'. '
' . esc_html__( 'You can find ', 'post-smtp' ) . '' . esc_html__( 'the API key', 'post-smtp' ) . '' . esc_html__( ' in your Mailersend account.', 'post-smtp' ) . '
' .'
'; return $html; } /** * Render Mailgun Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_mailgun_settings() { $api_key = null !== $this->options->getMailgunApiKey() ? esc_attr ( $this->options->getMailgunApiKey() ) : ''; $domain_name = null !== $this->options->getMailgunDomainName() ? esc_attr ( $this->options->getMailgunDomainName() ) : ''; $region = null !== $this->options->getMailgunRegion() ? ' checked' : ''; $html = '

' . esc_html__( 'It is easy to integrate Mailgun mailer to your WordPress website. We recommend you to ', 'post-smtp' ) . '' . esc_html__( 'check the documentation', 'post-smtp' ) . '' . esc_html__( ' for a successful integration.', 'post-smtp' ) . '

'; $html .= '
'. /** * Translators: %1$s Text, %2$s URL, %3$s URL Text, %4$s Text, %5$s URL, %6$s URL Text */ sprintf( '
%1$s %3$s
%4$s %6$s
', __( 'Create an account at', 'post-smtp' ), esc_url( 'https://www.mailgun.com/' ), esc_attr( 'Mailgun' ), __( 'If you are already logged in follow this link to get an', 'post-smtp' ), esc_url( 'https://app.mailgun.com/settings/api_security' ), __( 'API Key.', 'post-smtp' ) ) .'
'; $html .= '
'. /** * Translators: %1$s Text, %2$s URL, %3$s URL Text, %4$s Text, %5$s URL, %6$s URL Text */ sprintf( '%1$s %3$s', __( ' Follow this link to get the Mailgun', 'post-smtp' ), esc_url( 'https://app.mailgun.com/app/sending/domains' ), __( 'Domain Name.', 'post-smtp' ) ) .'
'; $html .= '
'. '
' . esc_html__( 'Set your endpoint in Europe if your business operates under EU laws. ', 'post-smtp' ) . '' . esc_html__( 'Learn', 'post-smtp' ) . '
' .'
'; return $html; } /** * Render Brevo Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_brevo_settings() { $api_key = null !== $this->options->getSendinblueApiKey() ? esc_attr ( $this->options->getSendinblueApiKey() ) : ''; $html = '

' . esc_html__( 'It is easy to integrate Brevo mailer to your WordPress website. We recommend you to check the documentation for a successful integration.', 'post-smtp' ) . '

'; $html .= '
'. /** * Translators: %1$s Text, %2$s URL, %3$s URL Text, %4$s Text, %5$s URL, %6$s URL Text */ '
' . esc_html__( 'You can find ', 'post-smtp' ) . '' . esc_html__( 'the API key', 'post-smtp' ) . '' . esc_html__( ' in your Brevo account.', 'post-smtp' ) . '
' . '
'; return $html; } /** * Render Mailtrap Settings * * @since 2.9.0 * @version 1.0.0 */ public function render_mailtrap_settings() { $api_key = null !== $this->options->getMailtrapApiKey() ? esc_attr ( $this->options->getMailtrapApiKey() ) : ''; $html = '

' . esc_html__( 'It is easy to integrate Mailtrap mailer to your WordPress website. We recommend you to check the documentation for a successful integration.', 'post-smtp' ) . '

'; $html .= '
'. /** * Translators: %1$s Text, %2$s URL, %3$s URL Text, %4$s Text, %5$s URL, %6$s URL Text */ '
' . esc_html__( 'You can find ', 'post-smtp' ) . '' . esc_html__( 'the API token', 'post-smtp' ) . '' . esc_html__( ' in your Mailtrap account.', 'post-smtp' ) . '
' . '
'; return $html; } /** * Render Resend Settings * * @since 3.2.0 * @version 1.0.0 */ public function render_resend_settings() { $api_key = null !== $this->options->getResendApiKey() ? esc_attr ( $this->options->getResendApiKey() ) : ''; $html = sprintf( '

Resend %2$s

%3$s

%4$s %6$s', esc_url( 'https://resend.com/' ), __( 'is a modern email API provider built for developers. It provides reliable email delivery with simple APIs and excellent deliverability.', 'post-smtp' ), __( 'Resend offers a free plan to send up to 100 emails per day and 3,000 emails per month. You can start testing immediately and upgrade when needed.', 'post-smtp' ), __( 'Let\'s get started with our', 'post-smtp' ), esc_url( 'https://postmansmtp.com/documentation/sockets-addons/how-to-setup-resend-with-post-smtp/' ), __( 'Resend Documentation', 'post-smtp' ) ); $html .= '

'. /** * Translators: %1$s Text, %2$s URL, %3$s URL Text, %4$s Text, %5$s URL, %6$s URL Text */ sprintf( '
%1$s %3$s
%4$s %6$s
', __( 'Create an account at', 'post-smtp' ), esc_url( 'https://resend.com/' ), esc_attr( 'Resend.com' ), __( 'If you are already logged in follow this link to get an', 'post-smtp' ), esc_url( 'https://resend.com/api-keys' ), __( 'API Key.', 'post-smtp' ) ) . '
'; return $html; } /** * Render Postmark Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_postmark_settings() { $api_key = null !== $this->options->getPostmarkApiKey() ? esc_attr ( $this->options->getPostmarkApiKey() ) : ''; $html = '

' . esc_html__( 'It is easy to integrate Postmark mailer to your WordPress website. We recommend you to ', 'post-smtp' ) . '' . esc_html__( 'check the documentation', 'post-smtp' ) . '' . esc_html__( ' for a successful integration.', 'post-smtp' ) . '

'; $html .= '
'. /** * Translators: %1$s Text, %2$s URL, %3$s URL Text, %4$s Text, %5$s URL, %6$s URL Text */ '
' . esc_html__( 'You can find ', 'post-smtp' ) . '' . esc_html__( 'the API tokens', 'post-smtp' ) . '' . esc_html__( ' in your Postmark account.', 'post-smtp' ) . '
' .'
'; return $html; } /** * Render Sparkpost Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_sparkpost_settings() { $api_key = null !== $this->options->getSparkPostApiKey() ? esc_attr ( $this->options->getSparkPostApiKey() ) : ''; $html = '

' . esc_html__( 'It is easy to integrate SparkPost mailer to your WordPress website. We recommend you to ', 'post-smtp' ) . '' . esc_html__( 'check the documentation', 'post-smtp' ) . '' . esc_html__( ' for a successful integration.', 'post-smtp' ) . '

'; $html .= '
'. /** * Translators: %1$s Text, %2$s URL, %3$s URL Text, %4$s Text, %5$s URL, %6$s URL Text */ '
' . esc_html__( 'You can find ', 'post-smtp' ) . '' . esc_html__( 'the API key', 'post-smtp' ) . '' . esc_html__( ' in your SparkPost account.', 'post-smtp' ) . '
' .'
'; return $html; } /** * Render ElasticEmail Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_elasticemail_settings() { $api_key = null !== $this->options->getElasticEmailApiKey() ? esc_attr ( $this->options->getElasticEmailApiKey() ) : ''; $html = '

' . esc_html__( 'It is easy to integrate Elastic Email mailer to your WordPress website. We recommend you to ', 'post-smtp' ) . '' . esc_html__( 'check the documentation', 'post-smtp' ) . '' . esc_html__( ' for a successful integration.', 'post-smtp' ) . '

'; $html .= '
'. /** * Translators: %1$s Text, %2$s URL, %3$s URL Text, %4$s Text, %5$s URL, %6$s URL Text */ '
' . esc_html__( 'You can find ', 'post-smtp' ) . '' . esc_html__( 'the API key', 'post-smtp' ) . '' . esc_html__( ' in your Elastic Email account.', 'post-smtp' ) . '
' . '
'; return $html; } /** * Render Mailjet Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_mailjet_settings() { $api_key = null !== $this->options->getMailjetApiKey() ? esc_attr ( $this->options->getMailjetApiKey() ) : ''; $secret_key = null !== $this->options->getMailjetApiKey() ? esc_attr ( $this->options->getMailjetSecretKey() ) : ''; $html = '

' . esc_html__( 'It is easy to integrate Mailjet mailer to your WordPress website. We recommend you to ', 'post-smtp' ) . '' . esc_html__( 'check the documentation', 'post-smtp' ) . '' . esc_html__( ' for a successful integration.', 'post-smtp' ) . '

'; $html .= '
'; $html .= '
'. /** * Translators: %1$s Text, %2$s URL, %3$s URL Text, %4$s Text, %5$s URL, %6$s URL Text */ '
' . esc_html__( 'You can find ', 'post-smtp' ) . '' . esc_html__( 'API and Access information', 'post-smtp' ) . '' . esc_html__( ' in your Mailjet account.', 'post-smtp' ) . '
' . '
'; return $html; } /** * Render SendPulse Settings * * @since 2.9.0 * @version 1.0.0 */ public function render_sendpulse_settings() { $api_key = null !== $this->options->getSendpulseApiKey() ? esc_attr ( $this->options->getSendpulseApiKey() ) : ''; $secret_key = null !== $this->options->getSendpulseSecretKey() ? esc_attr ( $this->options->getSendpulseSecretKey() ) : ''; $html = '

' . esc_html__( 'It is easy to integrate SendPulse mailer to your WordPress website. We recommend you to ', 'post-smtp' ) . '' . esc_html__( 'check the documentation', 'post-smtp' ) . '' . esc_html__( ' for a successful integration.', 'post-smtp' ) . '

'; $html .= '
'. sprintf( '
%2$s %3$s
', esc_url( 'https://sendpulse.com/features/transactional' ), __( 'Click here', 'post-smtp' ), __( 'to create an account at SendPulse', 'post-smtp' ) ). sprintf( '
%1$s%3$s
', __( 'If you are already logged in follow this ink to get your API ID from Sendpulse ', 'post-smtp' ), esc_url( 'https://login.sendpulse.com/settings/#api' ), __( 'Get API ID', 'post-smtp' ) ). '
' ; $html .= '
'. /** * Translators: %1$s Text, %2$s URL, %3$s URL Text, %4$s Text, %5$s URL, %6$s URL Text */ '
' . esc_html__( 'You can find ', 'post-smtp' ) . '' . esc_html__( 'the API credentials', 'post-smtp' ) . '' . esc_html__( ' in your SendPulse account.', 'post-smtp' ) . '
' . '
'; return $html; } /** * Render Amazon SES Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_amazonses_settings() { $access_key_id = isset( $this->options_array[ PostSMTPSES\PostSmtpAmazonSesTransport::OPTION_ACCESS_KEY_ID ] ) ? base64_decode( $this->options_array[ PostSMTPSES\PostSmtpAmazonSesTransport::OPTION_ACCESS_KEY_ID ] ) : ''; $access_key_secret = isset( $this->options_array[ PostSMTPSES\PostSmtpAmazonSesTransport::OPTION_SECRET_ACCESS_KEY ] ) ? base64_decode( $this->options_array[ PostSMTPSES\PostSmtpAmazonSesTransport::OPTION_SECRET_ACCESS_KEY ] ) : ''; $region = isset( $this->options_array[ PostSMTPSES\PostSmtpAmazonSesTransport::OPTION_REGION ] ) ? $this->options_array[ PostSMTPSES\PostSmtpAmazonSesTransport::OPTION_REGION ] : ''; $html = '

' . esc_html__( 'Due to the technical nature of this SMTP implementation, it is recommended to study this step-by-step guide at the time of setup.', 'post-smtp' ) . '

'; $html .= '

⚠️ ' . esc_html__( 'You must have a working SSL certificate installed on your WordPress site to use it with Amazon SES.', 'post-smtp' ) . '

'; $html .= '
'; $html .= '
'. /** * Translators: %1$s Text, %2$s URL, %3$s URL Text, %4$s Text, %5$s URL, %6$s URL Text */ '
' . esc_html__( 'If you are already logged in, ', 'post-smtp' ) . '' . esc_html__( 'visit this link', 'post-smtp' ) . '' . esc_html__( ' to get the Access Key ID and Secret Access Key.', 'post-smtp' ) . '
' . '
'; $html .= '
' . esc_html__( 'Enter the correct region', 'post-smtp' ) . '
'; return $html; } /** * Render Office365 Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_office365_settings() { $options = get_option( PostmanOptions::POSTMAN_OPTIONS ); $app_client_id = isset( $options['office365_app_id'] ) ? base64_decode( $options['office365_app_id'] ) : ''; $app_client_secret = isset( $options['office365_app_password'] ) ? base64_decode( $options['office365_app_password'] ) : ''; $redirect_uri = admin_url(); // Check if access token exists for Office 365 $office365_oauth = get_option( 'postman_office365_oauth' ); $has_access_token = $office365_oauth && isset( $office365_oauth['access_token'] ) && ! empty( $office365_oauth['access_token'] ); // Retrieve options for premium features and extensions $post_smtp_pro_options = get_option( 'post_smtp_pro', [] ); $postman_office365_auth_token = get_option( 'postman_office365_oauth' ); $extensions = isset( $post_smtp_pro_options['extensions'] ) ? $post_smtp_pro_options['extensions'] : []; $office365_oneclick_enabled = in_array( 'microsoft-one-click', $extensions ); $office365_auth_url = get_option( 'post_smtp_office365_auth_url' ); $html = '

' . esc_html__( 'To establish a SMTP connection, you will need to create an app in your Azure account. This step-by-step guide will walk you through the whole process.', 'post-smtp' ) . '

'; // Setup classes and attributes for form visibility $hidden_class = $office365_oneclick_enabled ? 'ps-hidden' : ''; // Conditional 'required' attribute for the fields - consider access token when one-click is enabled $client_secret_required = $office365_oneclick_enabled ? '' : 'required'; $client_id_required = $office365_oneclick_enabled ? '' : 'required'; $one_click_class = 'ps-enable-office365-one-click'; $url = POST_SMTP_URL . '/Postman/Wizard/assets/images/ms365.png'; $transport_name = __( 'One-Click Microsoft Mailer Setup?', 'post-smtp' ); $product_url = postman_is_bfcm() ? 'https://postmansmtp.com/cyber-monday-sale?utm_source=plugin&utm_medium=section_name&utm_campaign=BFCM&utm_id=BFCM_2024' : 'https://postmansmtp.com/pricing/?utm_source=plugin&utm_medium=wizard_microsoft&utm_campaign=plugin'; // Prepare data for JSON encoding $data = [ 'url' => $url, 'transport_name' => $transport_name, 'product_url' => $product_url ]; $json_data = htmlspecialchars( json_encode( $data ), ENT_QUOTES, 'UTF-8' ); // Determine whether we have both token and email stored for Office365 // Only treat stored user_email as valid when one-click is enabled. $has_email = false; if ( $office365_oneclick_enabled && $office365_oauth && isset( $office365_oauth['user_email'] ) && ! empty( $office365_oauth['user_email'] ) ) { $has_email = true; } // Set required based on context: // - For one-click: skip if success param is set OR both access token and email exist // - For normal setup: skip if success param is set OR both access token and email exist if ( $office365_oneclick_enabled ) { $required = ( ( isset( $_GET['success'] ) && $_GET['success'] == 1 ) || ( $has_access_token && $has_email ) ) ? '' : 'required'; } else { $required = ( ( isset( $_GET['success'] ) && $_GET['success'] == 1 ) || ( $has_access_token && $has_email ) ) && $client_id_required ? '' : 'required'; } $html .= __( 'The configuration steps are more technical than other options, so our detailed guide will walk you through the whole process.', 'post-smtp' ); $html .= '
'; if ( post_smtp_has_pro() ) { $one_click = true; $html .= sprintf( '

%1$s

', __( 'One-Click Setup', 'post-smtp' ) ); } else { $html .= sprintf( '

%1$s %2$s

', __( 'One-Click Setup', 'post-smtp' ), __( 'PRO', 'post-smtp' ) ); $one_click = 'disabled'; $one_click_class .= ' disabled'; } $html .= __( 'Enable the option for a quick and easy way to connect with Microsoft 365 / Outlook without the need of manually creating an app', 'post-smtp' ); // Check if user has business plan for Office 365 one-click $is_business_plan = false; if ( function_exists( 'pspro_fs' ) && pspro_fs()->is_plan( 'business' ) ) { $is_business_plan = true; } // Check Post SMTP Pro version if user has business plan $show_version_warning = false; $required_pro_version = '1.5.0'; if ( $is_business_plan && defined( 'POST_SMTP_PRO_VERSION' ) ) { $current_pro_version = POST_SMTP_PRO_VERSION; if ( version_compare( $current_pro_version, $required_pro_version, '<' ) ) { $show_version_warning = true; } } // One-click switch control $html .= "
"; // Show business plan upgrade notice if needed if ( post_smtp_has_pro() && !$is_business_plan ) { $html .= '
'; $html .= '

' . __( 'Microsoft 365 (Outlook)', 'post-smtp' ) . '
'; $html .= __( ' One-Click Setup is available only with Business plan. Click on the toggle to update.', 'post-smtp' ) . '

'; $html .= '
'; // Inject conditional CSS add_action( 'admin_footer', function () { echo ''; }); } // Show version warning if user has business plan but outdated Post SMTP Pro version if ( $show_version_warning ) { $html .= '
'; $html .= '

' . __( 'Please update your Post SMTP Pro plugin to use this feature.', 'post-smtp' ) . '

'; $html .= '
'; } $html .= '
'; $html .= sprintf( '

%2$s %3$s

%5$s', esc_url( 'https://azure.microsoft.com/en-us/pricing/purchase-options/azure-account?icid=azurefreeaccount' ), __( 'Office 365', 'post-smtp' ), __( 'is a popular transactional email provider that sends more than 35 billion emails every month. If you\'re just starting out, the free plan allows you to send up to 100 emails each day without entering your credit card details', 'post-smtp' ), esc_url( 'https://postmansmtp.com/docs/mailers/microsoft-365-one-click-smtp/' ), __( 'Read how to setup Office 365', 'post-smtp' ) ); $html .= '
'. '
' . esc_html__( 'You can find the ', 'post-smtp' ) . '' . esc_html__( 'client id', 'post-smtp' ) . '' . esc_html__( ' here.', 'post-smtp' ) . '
' .'
'; $html .= '
'. /** * Translators: %1$s URL, %2$s URL Text, %3$s Text */ '
' . esc_html__( 'You can find the ', 'post-smtp' ) . '' . esc_html__( 'client secret', 'post-smtp' ) . '' . esc_html__( ' here.', 'post-smtp' ) . '
' .'
'; $html .= '
'. /** * Translators: %1$s URL, %2$s URL Text, %3$s Text */ '
' . esc_html__( 'You can place the ', 'post-smtp' ) . '' . esc_html__( 'redirect url', 'post-smtp' ) . '' . esc_html__( ' as needed.', 'post-smtp' ) . '
' .'
'; $html .= '

'.__( 'Authorization (Required)', 'post-smtp' ).'

'.__( 'Before continuing, you\'ll need to allow this plugin to send emails using your Office 365 account.', 'post-smtp' ).'

Connect to Office 365'; $html .= '
'; $html .= '
'; if ( post_smtp_has_pro() ) { if ( $postman_office365_auth_token && isset( $postman_office365_auth_token['user_email'] ) ) { $nonce = wp_create_nonce( 'remove_365_oauth_action' ); $action_url = esc_url( add_query_arg( [ '_wpnonce' => $nonce, 'action' => 'remove_365_oauth_action', ], admin_url( 'admin-post.php' ) ) ); if ( isset( $postman_office365_auth_token['user_email'] ) ) { $html .= ' ' . sprintf( esc_html__('Connected with: %s', 'post-smtp'), esc_html( $postman_office365_auth_token['user_email'] ) ) . ''; } $html .= ''; $html .= esc_html__( 'Remove Authorization', 'post-smtp' ); $html .= ''; }else { $html .= '

' . esc_html__( 'Authorization (Required)', 'post-smtp' ) . '

'; $html .= '

' . esc_html__( 'Before continuing, you\'ll need to allow this plugin to send emails using Office 365 API.', 'post-smtp' ) . '

'; $html .= ''; $html .= ''; $html .= esc_html__( 'Sign in with Microsoft', 'post-smtp' ); $html .= ''; } } $html .= '
'; return $html; } /** * Render Gmail API Settings * * @since 2.7.0 * @version 1.0.0 */ public function render_zoho_settings() { $regions = array( 'com' => __( 'United States (US)', 'postsmtp-zoho' ), 'eu' => __( 'Europe (EU)', 'postsmtp-zoho' ), 'in' => __( 'India (IN)', 'postsmtp-zoho' ), 'com.cn' => __( 'China (CN)', 'postsmtp-zoho' ), 'com.au' => __( 'Australia (AU)', 'postsmtp-zoho' ), 'jp' => __( 'Japan (JP)', 'postsmtp-zoho' ), ); $selected_region = isset( $this->options_array[ ZohoMailPostSMTP\ZohoMailTransport::OPTION_REGION ] ) ? $this->options_array[ ZohoMailPostSMTP\ZohoMailTransport::OPTION_REGION ]: ''; $client_id = isset( $this->options_array[ ZohoMailPostSMTP\ZohoMailTransport::OPTION_CLIENT_ID ] ) ? $this->options_array[ ZohoMailPostSMTP\ZohoMailTransport::OPTION_CLIENT_ID ] : ''; $client_secret = isset( $this->options_array[ ZohoMailPostSMTP\ZohoMailTransport::OPTION_CLIENT_SECRET ] ) ? base64_decode( $this->options_array[ ZohoMailPostSMTP\ZohoMailTransport::OPTION_CLIENT_SECRET ] ) : ''; $required = ( isset( $_GET['success'] ) && $_GET['success'] == 1 ) ? '' : 'required'; $html = '

' . esc_html__( 'It is recommended to study the ', 'post-smtp' ) . '' . esc_html__( 'Zoho Mail integration doc', 'post-smtp' ) . '' . esc_html__( ' at the time of setup.', 'post-smtp' ) . '

'; $html .= '
'; $html .= '
'; $html .= '
' . esc_html__( 'Check your ', 'post-smtp' ) . '' . esc_html__( 'Zoho API credentials', 'post-smtp' ) . '' . esc_html__( ' to find the Client ID and Secret.', 'post-smtp' ) . '
'; $html .= '
'.__( 'Please copy this URL into the "Redirect URL" field of your Zoho account settings.', 'post-smtp' ).'
'; $html .= '

'.__( 'Authorization (Required)', 'post-smtp' ).'

'.__( 'Before continuing, you\'ll need to allow this plugin to send emails using Zoho.', 'post-smtp' ).'

Connect to Zoho'; return $html; } public function render_smtp2go_settings() { ob_start(); $api_key = null === $this->options->getSmtp2GoApiKey() ? '' : esc_attr( $this->options->getSmtp2GoApiKey() ); echo '

' . esc_html__( 'It is easy to integrate SMTP2GO mailer to your WordPress website. We recommend you to ', 'post-smtp' ) . '' . esc_html__( 'check the documentation', 'post-smtp' ) . '' . esc_html__( ' for a successful integration.', 'post-smtp' ) . '

'; echo '
'; echo '
' . esc_html__( 'You can find ', 'post-smtp' ) . '' . esc_html__( 'the API key', 'post-smtp' ) . '' . esc_html__( ' in your SMTP2GO account.', 'post-smtp' ) . '
'; echo '
'; return ob_get_clean(); } /** * Save Wizard | AJAX Callback * * @since 2.7.0 * @version 1.0.0 */ public function save_wizard() { $form_data = array(); parse_str( $_POST['FormData'], $form_data ); $response = false; if( isset( $_POST['action'] ) && 'ps-save-wizard' == $_POST['action'] && isset( $form_data['security'] ) && wp_verify_nonce( $form_data['security'], 'post-smtp' ) ) { if( isset( $form_data['postman_options'] ) && !empty( $form_data['postman_options'] ) ) { $sanitized = post_smtp_sanitize_array( $form_data['postman_options'] ); $options = get_option( PostmanOptions::POSTMAN_OPTIONS ); $_options = $options; $options = $options ? $options : array(); //for the checkboxes $sanitized['prevent_sender_email_override'] = isset( $sanitized['prevent_sender_email_override'] ) ? 1 : ''; $sanitized['prevent_sender_name_override'] = isset( $sanitized['prevent_sender_name_override'] ) ? 1 : ''; //Envelop Email Address $sanitized['envelope_sender'] = isset( $sanitized['sender_email'] ) ? $sanitized['sender_email'] : ''; //Encode API Keys $sanitized['office365_app_id'] = isset( $sanitized['office365_app_id'] ) ? $sanitized['office365_app_id'] : ''; $sanitized['office365_app_password'] = isset( $sanitized['office365_app_password'] ) ? $sanitized['office365_app_password'] : ''; $sanitized[PostmanOptions::SENDINBLUE_API_KEY] = isset( $sanitized[PostmanOptions::SENDINBLUE_API_KEY] ) ? $sanitized[PostmanOptions::SENDINBLUE_API_KEY] : ''; $sanitized[PostmanOptions::MAILTRAP_API_KEY] = isset( $sanitized[PostmanOptions::MAILTRAP_API_KEY] ) ? $sanitized[PostmanOptions::MAILTRAP_API_KEY] : ''; $sanitized['sparkpost_api_key'] = isset( $sanitized['sparkpost_api_key'] ) ? $sanitized['sparkpost_api_key'] : ''; $sanitized['postmark_api_key'] = isset( $sanitized['postmark_api_key'] ) ? $sanitized['postmark_api_key'] : ''; $sanitized['mailgun_api_key'] = isset( $sanitized['mailgun_api_key'] ) ? $sanitized['mailgun_api_key'] : ''; $sanitized[PostmanOptions::SENDGRID_API_KEY] = isset( $sanitized[PostmanOptions::SENDGRID_API_KEY] ) ? $sanitized[PostmanOptions::SENDGRID_API_KEY] : ''; $sanitized['sendgrid_region'] = isset( $sanitized['sendgrid_region'] ) ? $sanitized['sendgrid_region'] : ''; $sanitized['resend_api_key'] = isset( $sanitized['resend_api_key'] ) ? $sanitized['resend_api_key'] : ''; $sanitized[PostmanOptions::EMAILIT_API_KEY] = isset( $sanitized[PostmanOptions::EMAILIT_API_KEY] ) ? $sanitized[PostmanOptions::EMAILIT_API_KEY] : ''; $sanitized[PostmanOptions::MAILEROO_API_KEY] = isset( $sanitized[PostmanOptions::MAILEROO_API_KEY] ) ? $sanitized[PostmanOptions::MAILEROO_API_KEY] : ''; $sanitized[PostmanOptions::SWEEGO_API_KEY] = isset( $sanitized[PostmanOptions::SWEEGO_API_KEY] ) ? $sanitized[PostmanOptions::SWEEGO_API_KEY] : ''; $sanitized['mandrill_api_key'] = isset( $sanitized['mandrill_api_key'] ) ? $sanitized['mandrill_api_key'] : ''; $sanitized[PostmanOptions::MAILERSEND_API_KEY] = isset( $sanitized[PostmanOptions::MAILERSEND_API_KEY] ) ? $sanitized[PostmanOptions::MAILERSEND_API_KEY] : ''; $sanitized['elasticemail_api_key'] = isset( $sanitized['elasticemail_api_key'] ) ? $sanitized['elasticemail_api_key'] : ''; $sanitized[PostmanOptions::MAILJET_API_KEY] = isset( $sanitized[PostmanOptions::MAILJET_API_KEY] ) ? $sanitized[PostmanOptions::MAILJET_API_KEY] : ''; $sanitized[PostmanOptions::MAILJET_SECRET_KEY] = isset( $sanitized[PostmanOptions::MAILJET_SECRET_KEY] ) ? $sanitized[PostmanOptions::MAILJET_SECRET_KEY] : ''; $sanitized['basic_auth_password'] = isset( $sanitized['basic_auth_password'] ) ? $sanitized['basic_auth_password'] : ''; $sanitized['ses_access_key_id'] = isset( $sanitized['ses_access_key_id'] ) ? $sanitized['ses_access_key_id'] : ''; $sanitized['ses_secret_access_key'] = isset( $sanitized['ses_secret_access_key'] ) ? $sanitized['ses_secret_access_key'] : ''; $sanitized['ses_region'] = isset( $sanitized['ses_region'] ) ? $sanitized['ses_region'] : ''; $sanitized['enc_type'] = 'tls'; $sanitized['auth_type'] = 'login'; $sanitized['slack_token'] = base64_decode( isset( $options['slack_token'] ) ? $options['slack_token'] : '' ); $sanitized['pushover_user'] = base64_decode( isset( $options['pushover_user'] ) ? $options['pushover_user'] : '' ); $sanitized['pushover_token'] = base64_decode( isset( $options['pushover_token'] ) ? $options['pushover_token'] : '' ); foreach( $sanitized as $key => $value ) { $options[$key] = $value; } if( $options == $_options ) { $response = true; } else { $response = update_option( PostmanOptions::POSTMAN_OPTIONS , $options ); } } } //Prevent redirection delete_transient( PostmanSession::ACTION ); wp_send_json( array(), 200 ); } /** * Callback function to handle AJAX requests for updating the 'post_smtp_pro' option. * * This function listens for AJAX requests and updates the 'bonus_extensions' array * in the 'post_smtp_pro' option. It adds or removes the 'gmail-oneclick' extension * based on whether the checkbox is checked or not. * * @return void */ public function update_post_smtp_pro_option_callback() { // Capability check: Only allow admins if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( array( 'message' => 'Unauthorized.' ) ); return; } // Nonce check for CSRF protection if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'update_post_smtp_pro_option' ) ) { wp_send_json_error( array( 'message' => 'Invalid or missing nonce.' ) ); return; } if ( ! isset( $_POST['enabled'] ) ) { wp_send_json_error( array( 'message' => 'Invalid request.' ) ); return; } $options = get_option( 'post_smtp_pro', [] ); if ( ! isset( $options['extensions'] ) ) { $options['extensions'] = []; } $enabled_value = sanitize_text_field( $_POST['enabled'] ); if ( ! empty( $enabled_value ) ) { if ( ! in_array( $enabled_value, $options['extensions'] ) ) { $options['extensions'][] = $enabled_value; } } else { $options['extensions'] = array_diff( $options['extensions'], ['gmail-oneclick'] ); } update_option( 'post_smtp_pro', $options ); wp_send_json_success( array( 'message' => 'Option updated successfully!' ) ); } /** * Update Post SMTP Pro Option for Office365 One-Click * * @since 2.7.0 * @version 1.0.0 * * @return void */ public function update_post_smtp_pro_option_office365_callback() { // Capability check: Only allow admins if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( array( 'message' => 'Unauthorized.' ) ); return; } // Nonce check for CSRF protection if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'update_post_smtp_pro_option' ) ) { wp_send_json_error( array( 'message' => 'Invalid or missing nonce.' ) ); return; } if ( ! isset( $_POST['enabled'] ) ) { wp_send_json_error( array( 'message' => 'Invalid request.' ) ); return; } $options = get_option( 'post_smtp_pro', [] ); if ( ! isset( $options['extensions'] ) ) { $options['extensions'] = []; } $enabled_value = sanitize_text_field( $_POST['enabled'] ); // Check version requirement for Office 365 one-click if ( ! empty( $enabled_value ) ) { $required_pro_version = '1.5.0'; if ( defined( 'POST_SMTP_PRO_VERSION' ) ) { $current_pro_version = POST_SMTP_PRO_VERSION; if ( version_compare( $current_pro_version, $required_pro_version, '<' ) ) { wp_send_json_error( array( 'message' => sprintf( __( 'Post SMTP Pro version %1$s or higher is required for Office 365 One-Click Setup. Current version: %2$s', 'post-smtp' ), $required_pro_version, $current_pro_version ) ) ); return; } } else { wp_send_json_error( array( 'message' => 'Post SMTP Pro version could not be determined.' ) ); return; } } // Remove existing Office 365 related extensions $options['extensions'] = array_diff( $options['extensions'], ['microsoft-365', 'microsoft-one-click'] ); if ( ! empty( $enabled_value ) ) { // If one-click is enabled, add both microsoft-365 and microsoft-one-click $options['extensions'][] = 'microsoft-365'; $options['extensions'][] = 'microsoft-one-click'; } else { // If one-click is disabled, only add microsoft-365 $options['extensions'][] = 'microsoft-365'; } // Remove duplicates $options['extensions'] = array_unique( $options['extensions'] ); update_option( 'post_smtp_pro', $options ); // Check for Office 365 OAuth token and user email $office365_oauth = get_option( 'postman_office365_oauth' ); $has_access_token = false; $has_email = false; $user_email = ''; if ( $office365_oauth && is_array( $office365_oauth ) ) { if ( isset( $office365_oauth['access_token'] ) && ! empty( $office365_oauth['access_token'] ) ) { $has_access_token = true; } if ( isset( $office365_oauth['user_email'] ) && ! empty( $office365_oauth['user_email'] ) ) { $has_email = true; $user_email = sanitize_email( $office365_oauth['user_email'] ); } } wp_send_json_success( array( 'message' => 'Option updated successfully!', 'has_access_token' => $has_access_token, 'has_email' => $has_email, 'user_email' => $user_email, ) ); } /** * Redirect to Zoho Authentication * * @since 2.7.0 * @version 1.0.0 */ public function auth_zoho() { $zoho_mailer = new PostSMTP_ZohoMail(); $oauthClient = $zoho_mailer->zohomail_configuration(); $PostmanOauthClient = new ZohoMailPostSMTP\ZohoMailOauth( $oauthClient ); $state = get_transient( PostSMTP_ZohoMail::STATE ); // Save client state so we can validate in response if ( $state === false ) { $state = bin2hex( random_bytes( 32 / 2 ) ); set_transient( PostSMTP_ZohoMail::STATE, $state, 5 * MINUTE_IN_SECONDS ); } // // Generate the auth URL $redirect_url = $PostmanOauthClient->getZohoMailAuthURL( array( 'state' => $state, ) ); wp_redirect( $redirect_url ); } /** * Handles the removal of Office 365 OAuth credentials from the WordPress database. * * This function removes only the sensitive fields (tokens, email, and expiration) * from the stored Office 365 OAuth option instead of deleting the entire record. */ public function post_smtp_remove_365_oauth_action() { // Verify nonce for security if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], 'remove_365_oauth_action' ) ) { wp_die( esc_html__( 'Nonce verification failed. Please try again.', 'post-smtp' ) ); } // Get the saved Office 365 OAuth data $oauth_data = get_option( 'postman_office365_oauth', [] ); if ( ! empty( $oauth_data ) && is_array( $oauth_data ) ) { // Unset only sensitive fields unset( $oauth_data['access_token'], $oauth_data['refresh_token'], $oauth_data['token_expires'], $oauth_data['user_email'] ); // Update the option with sanitized data update_option( 'postman_office365_oauth', $oauth_data ); } // Redirect back to configuration wizard page wp_redirect( admin_url( "admin.php?socket=office365_api&step=2&page=postman/configuration_wizard" ) ); exit; } /** * Handles the Office 365 OAuth redirect, retrieves the token parameters from the URL, * saves them in WordPress options, and redirects the user to a settings page. * * This function is used when OAuth authorization is completed and the user is * redirected back with the access token, refresh token, expiration time, message, * and user email. It sanitizes the URL parameters and saves them to the WordPress * options table to be used later in the application. * * After processing, the user is redirected to a settings page for confirmation. */ public function handle_office365_oauth_redirect() { // Check if the required OAuth parameters are present in the URL. if ( isset( $_GET['action'] ) && $_GET['action'] === 'office365_oauth_redirect' ) { // Sanitize and retrieve URL parameters $access_token = sanitize_text_field( $_GET['access_token'] ); $refresh_token = isset( $_GET['refresh_token'] ) ? sanitize_text_field( $_GET['refresh_token'] ) : null; $expires_in = isset( $_GET['expires_in'] ) ? intval( $_GET['expires_in'] ) : 0; $msg = isset( $_GET['msg'] ) ? sanitize_text_field( $_GET['msg'] ) : ''; $user_email = isset( $_GET['user_email'] ) ? sanitize_email( $_GET['user_email'] ) : ''; $auth_token_expires = time() + $expires_in; $redirect_uri = admin_url(); // Prepare the OAuth data array for storing in WordPress options $oauth_data = array( 'access_token' => $access_token, 'refresh_token' => $refresh_token, 'token_expires' => $auth_token_expires, 'user_email' => $user_email, 'OAUTH_REDIRECT_URI' => $redirect_uri, 'OAUTH_SCOPES' => 'openid profile offline_access Mail.Send Mail.Send.Shared', 'OAUTH_AUTHORITY' => 'https://login.microsoftonline.com/common', 'OAUTH_AUTHORIZE_ENDPOINT' => '/oauth2/v2.0/authorize', 'OAUTH_TOKEN_ENDPOINT' => '/oauth2/v2.0/token', ); // Save the OAuth parameters to the WordPress options table. update_option( 'postman_office365_oauth', $oauth_data ); } } /** * Handles the removal of Gmail OAuth credentials from the WordPress database. * * This function processes a form submission to delete the stored OAuth access token * and user email associated with Gmail API integration. It validates the request's * nonce for security, performs the deletion, and redirects the user back to the settings * page with a success message. */ public function post_smtp_remove_oauth_action() { // Verify the nonce to ensure the request is secure and valid. if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], 'remove_oauth_action' ) ) { wp_die( esc_html__( 'Nonce verification failed. Please try again.', 'post-smtp' ) ); } // Remove the OAuth access token option from the WordPress database. delete_option( 'postman_auth_token' ); // Redirect the user back to the settings page with a success query parameter. wp_redirect( admin_url( "admin.php?socket=gmail_api&step=2&page=postman/configuration_wizard" ) ); // Terminate script execution to prevent further processing after the redirect. exit; } /** * Handles the OAuth redirect, retrieves the token parameters from the URL, * saves them in WordPress options, and redirects the user to a settings page. * * This function is used when OAuth authorization is completed and the user is * redirected back with the access token, refresh token, expiration time, message, * and user email. It sanitizes the URL parameters and saves them to the WordPress * options table to be used later in the application. * * After processing, the user is redirected to a settings page for confirmation. */ public function handle_gmail_oauth_redirect() { // Check if the required OAuth parameters are present in the URL. if ( isset( $_GET['action'] ) && $_GET['action'] === 'gmail_oauth_redirect' ) { // Capability check: Only allow administrators to update OAuth tokens if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'post-smtp' ) ); } // CSRF protection: Verify nonce (required by security report) if ( ! isset( $_GET['_wpnonce'] ) || empty( $_GET['_wpnonce'] ) ) { wp_die( esc_html__( 'Security check failed. Nonce is missing.', 'post-smtp' ) ); } // Verify the nonce $nonce = sanitize_text_field( $_GET['_wpnonce'] ); if ( ! wp_verify_nonce( $nonce, 'gmail_oauth_redirect' ) ) { wp_die( esc_html__( 'Security check failed. Invalid nonce. Please try again.', 'post-smtp' ) ); } // Sanitize and retrieve URL parameters $access_token = isset( $_GET['access_token'] ) ? sanitize_text_field( $_GET['access_token'] ) : null; $refresh_token = isset( $_GET['refresh_token'] ) ? sanitize_text_field( $_GET['refresh_token'] ) : null; $expires_in = isset( $_GET['expires_in'] ) ? intval( $_GET['expires_in'] ) : 0; $msg = isset( $_GET['msg'] ) ? sanitize_text_field( $_GET['msg'] ) : ''; $user_email = isset( $_GET['user_email'] ) ? sanitize_email( $_GET['user_email'] ) : ''; $auth_token_expires = time() + $expires_in; if ( $access_token ) { $oauth_data = array( 'access_token' => $access_token, 'refresh_token' => $refresh_token, 'auth_token_expires'=> $auth_token_expires, 'vendor_name' => 'google', 'user_email' => $user_email, ); // Save the OAuth parameters to the WordPress options table. update_option( 'postman_auth_token', $oauth_data ); } } } } new Post_SMTP_New_Wizard(); endif;