芝麻web文件管理V1.00
编辑当前文件:/home/prismawe/clients/herve-tessa-maconnerie.fr/wp-content/plugins/easy-wp-smtp/easy-wp-smtp.php
'', 'from_name_field' => '', 'smtp_settings' => array( 'host' => 'smtp.example.com', 'type_encryption' => 'none', 'port' => 25, 'autentication' => 'yes', 'username' => 'yourusername', 'password' => 'yourpassword' ) ); /* install the default plugin options */ if ( ! get_option( 'swpsmtp_options' ) ){ add_option( 'swpsmtp_options', $swpsmtp_options_default, '', 'yes' ); } } } /** * Add action links on plugin page in to Plugin Name block * @param $links array() action links * @param $file string relative path to pugin "easy-wp-smtp/easy-wp-smtp.php" * @return $links array() action links */ if ( ! function_exists ( 'swpsmtp_plugin_action_links' ) ) { function swpsmtp_plugin_action_links( $links, $file ) { /* Static so we don't call plugin_basename on every plugin row. */ static $this_plugin; if ( ! $this_plugin ) { $this_plugin = plugin_basename( __FILE__ ); } if ( $file == $this_plugin ) { $settings_link = '
' . __( 'Settings', 'easy_wp_smtp' ) . '
'; array_unshift( $links, $settings_link ); } return $links; } } /** * Add action links on plugin page in to Plugin Description block * @param $links array() action links * @param $file string relative path to pugin "easy-wp-smtp/easy-wp-smtp.php" * @return $links array() action links */ if ( ! function_exists ( 'swpsmtp_register_plugin_links' ) ) { function swpsmtp_register_plugin_links( $links, $file ) { $base = plugin_basename( __FILE__ ); if ( $file == $base ) { $links[] = '
' . __( 'Settings', 'easy_wp_smtp' ) . '
'; } return $links; } } /** * Function to add plugin scripts * @return void */ if ( ! function_exists ( 'swpsmtp_admin_head' ) ) { function swpsmtp_admin_head() { wp_enqueue_style( 'swpsmtp_stylesheet', plugins_url( 'css/style.css', __FILE__ ) ); if ( isset( $_REQUEST['page'] ) && 'swpsmtp_settings' == $_REQUEST['page'] ) { wp_enqueue_script( 'swpsmtp_script', plugins_url( 'js/script.js', __FILE__ ), array( 'jquery' ) ); } } } /** * Function to add smtp options in the phpmailer_init * @return void */ if ( ! function_exists ( 'swpsmtp_init_smtp' ) ) { function swpsmtp_init_smtp( $phpmailer ) { $swpsmtp_options = get_option( 'swpsmtp_options' ); /* Set the mailer type as per config above, this overrides the already called isMail method */ $phpmailer->IsSMTP(); $from_email = $swpsmtp_options['from_email_field']; $phpmailer->From = $from_email; $from_name = $swpsmtp_options['from_name_field']; $phpmailer->FromName = $from_name; $phpmailer->SetFrom($phpmailer->From, $phpmailer->FromName); /* Set the SMTPSecure value */ if ( $swpsmtp_options['smtp_settings']['type_encryption'] !== 'none' ) { $phpmailer->SMTPSecure = $swpsmtp_options['smtp_settings']['type_encryption']; } /* Set the other options */ $phpmailer->Host = $swpsmtp_options['smtp_settings']['host']; $phpmailer->Port = $swpsmtp_options['smtp_settings']['port']; /* If we're using smtp auth, set the username & password */ if( 'yes' == $swpsmtp_options['smtp_settings']['autentication'] ){ $phpmailer->SMTPAuth = true; $phpmailer->Username = $swpsmtp_options['smtp_settings']['username']; $phpmailer->Password = swpsmtp_get_password(); } } } /** * View function the settings to send messages. * @return void */ if ( ! function_exists( 'swpsmtp_settings' ) ) { function swpsmtp_settings() { $display_add_options = $message = $error = $result = ''; $swpsmtp_options = get_option( 'swpsmtp_options' ); if ( isset( $_POST['swpsmtp_form_submit'] ) && check_admin_referer( plugin_basename( __FILE__ ), 'swpsmtp_nonce_name' ) ) { /* Update settings */ $swpsmtp_options['from_name_field'] = isset( $_POST['swpsmtp_from_name'] ) ? sanitize_text_field(wp_unslash($_POST['swpsmtp_from_name'])) : ''; if( isset( $_POST['swpsmtp_from_email'] ) ){ if( is_email( $_POST['swpsmtp_from_email'] ) ){ $swpsmtp_options['from_email_field'] = $_POST['swpsmtp_from_email']; } else{ $error .= " " . __( "Please enter a valid email address in the 'FROM' field.", 'easy_wp_smtp' ); } } $swpsmtp_options['smtp_settings']['host'] = sanitize_text_field($_POST['swpsmtp_smtp_host']); $swpsmtp_options['smtp_settings']['type_encryption'] = ( isset( $_POST['swpsmtp_smtp_type_encryption'] ) ) ? $_POST['swpsmtp_smtp_type_encryption'] : 'none' ; $swpsmtp_options['smtp_settings']['autentication'] = ( isset( $_POST['swpsmtp_smtp_autentication'] ) ) ? $_POST['swpsmtp_smtp_autentication'] : 'yes' ; $swpsmtp_options['smtp_settings']['username'] = sanitize_text_field($_POST['swpsmtp_smtp_username']); $smtp_password = trim($_POST['swpsmtp_smtp_password']); $swpsmtp_options['smtp_settings']['password'] = base64_encode($smtp_password); /* Check value from "SMTP port" option */ if ( isset( $_POST['swpsmtp_smtp_port'] ) ) { if ( empty( $_POST['swpsmtp_smtp_port'] ) || 1 > intval( $_POST['swpsmtp_smtp_port'] ) || ( ! preg_match( '/^\d+$/', $_POST['swpsmtp_smtp_port'] ) ) ) { $swpsmtp_options['smtp_settings']['port'] = '25'; $error .= " " . __( "Please enter a valid port in the 'SMTP Port' field.", 'easy_wp_smtp' ); } else { $swpsmtp_options['smtp_settings']['port'] = $_POST['swpsmtp_smtp_port']; } } /* Update settings in the database */ if ( empty( $error ) ) { update_option( 'swpsmtp_options', $swpsmtp_options ); $message .= __( "Settings saved.", 'easy_wp_smtp' ); } else{ $error .= " " . __( "Settings are not saved.", 'easy_wp_smtp' ); } } /* Send test letter */ if ( isset( $_POST['swpsmtp_test_submit'] ) && check_admin_referer( plugin_basename( __FILE__ ), 'swpsmtp_nonce_name' ) ) { if( isset( $_POST['swpsmtp_to'] ) ){ if( is_email( $_POST['swpsmtp_to'] ) ){ $swpsmtp_to =$_POST['swpsmtp_to']; } else{ $error .= " " . __( "Please enter a valid email address in the 'FROM' field.", 'easy_wp_smtp' ); } } $swpsmtp_subject = isset( $_POST['swpsmtp_subject'] ) ? $_POST['swpsmtp_subject'] : ''; $swpsmtp_message = isset( $_POST['swpsmtp_message'] ) ? $_POST['swpsmtp_message'] : ''; if( ! empty( $swpsmtp_to ) ) $result = swpsmtp_test_mail( $swpsmtp_to, $swpsmtp_subject, $swpsmtp_message ); } ?>
Please visit the
Easy WP SMTP
documentation page for usage instructions.
>
>
' />
/>
/>
/>
' />
/>
/>
' />
>
:
:
:
</textarea>
CharSet = $charset; $from_name = $swpsmtp_options['from_name_field']; $from_email = $swpsmtp_options['from_email_field']; $mail->IsSMTP(); /* If using smtp auth, set the username & password */ if( 'yes' == $swpsmtp_options['smtp_settings']['autentication'] ){ $mail->SMTPAuth = true; $mail->Username = $swpsmtp_options['smtp_settings']['username']; $mail->Password = swpsmtp_get_password(); } /* Set the SMTPSecure value, if set to none, leave this blank */ if ( $swpsmtp_options['smtp_settings']['type_encryption'] !== 'none' ) { $mail->SMTPSecure = $swpsmtp_options['smtp_settings']['type_encryption']; } /* Set the other options */ $mail->Host = $swpsmtp_options['smtp_settings']['host']; $mail->Port = $swpsmtp_options['smtp_settings']['port']; $mail->SetFrom( $from_email, $from_name ); $mail->isHTML( true ); $mail->Subject = $subject; $mail->MsgHTML( $message ); $mail->AddAddress( $to_email ); $mail->SMTPDebug = 0; /* Send mail and return result */ if ( ! $mail->Send() ) $errors = $mail->ErrorInfo; $mail->ClearAddresses(); $mail->ClearAllRecipients(); if ( ! empty( $errors ) ) { return $errors; } else{ return 'Test mail was sent'; } } } /** * Performed at uninstal. * @return void */ if ( ! function_exists( 'swpsmtp_send_uninstall' ) ) { function swpsmtp_send_uninstall() { /* delete plugin options */ delete_site_option( 'swpsmtp_options' ); delete_option( 'swpsmtp_options' ); } } if ( ! function_exists( 'swpsmtp_get_password' ) ) { function swpsmtp_get_password() { $swpsmtp_options = get_option( 'swpsmtp_options' ); $temp_password = $swpsmtp_options['smtp_settings']['password']; $password = ""; $decoded_pass = base64_decode($temp_password); /* no additional checks for servers that aren't configured with mbstring enabled */ if ( ! function_exists( 'mb_detect_encoding' ) ){ return $decoded_pass; } /* end of mbstring check */ if (base64_encode($decoded_pass) === $temp_password) { //it might be encoded if(false === mb_detect_encoding($decoded_pass)){ //could not find character encoding. $password = $temp_password; } else{ $password = base64_decode($temp_password); } } else{ //not encoded $password = $temp_password; } return $password; } } /** * Add all hooks */ add_filter( 'plugin_action_links', 'swpsmtp_plugin_action_links', 10, 2 ); add_filter( 'plugin_row_meta', 'swpsmtp_register_plugin_links', 10, 2 ); add_action( 'phpmailer_init','swpsmtp_init_smtp'); add_action( 'admin_menu', 'swpsmtp_admin_default_setup' ); add_action( 'admin_init', 'swpsmtp_admin_init' ); add_action( 'admin_enqueue_scripts', 'swpsmtp_admin_head' ); register_uninstall_hook( plugin_basename( __FILE__ ), 'swpsmtp_send_uninstall' );