'', 'mail_from_name' => '', 'mailer' => 'smtp', 'mail_set_return_path' => 'false', 'smtp_host' => 'localhost', 'smtp_port' => '25', 'smtp_ssl' => 'none', 'smtp_auth' => false, 'smtp_user' => '', 'smtp_pass' => '', 'pepipost_user' => '', 'pepipost_pass' => '', 'pepipost_port' => '2525', 'pepipost_ssl' => 'none', ); /** * Activation function. This function creates the required options and defaults. */ if ( ! function_exists( 'wp_mail_smtp_activate' ) ) : /** * What to do on plugin activation. */ function wp_mail_smtp_activate() { global $wpms_options; // Create the required options... foreach ( $wpms_options as $name => $val ) { add_option( $name, $val ); } } endif; if ( ! function_exists( 'wp_mail_smtp_whitelist_options' ) ) : /** * Whitelist plugin options. * * @param array $whitelist_options * * @return mixed */ function wp_mail_smtp_whitelist_options( $whitelist_options ) { global $wpms_options; // Add our options to the array. $whitelist_options['email'] = array_keys( $wpms_options ); return $whitelist_options; } endif; /** * To avoid any (very unlikely) clashes, check if the function already exists. */ if ( ! function_exists( 'phpmailer_init_smtp' ) ) : /** * This code is copied, from wp-includes/pluggable.php as at version 2.2.2. * * @param PHPMailer $phpmailer It's passed by reference, so no need to return anything. */ function phpmailer_init_smtp( $phpmailer ) { /* * If constants are defined, apply them. * We should have defined all required constants before using them. */ if ( defined( 'WPMS_ON' ) && WPMS_ON && defined( 'WPMS_MAILER' ) ) { $phpmailer->Mailer = WPMS_MAILER; if ( defined( 'WPMS_SET_RETURN_PATH' ) && WPMS_SET_RETURN_PATH ) { $phpmailer->Sender = $phpmailer->From; } if ( WPMS_MAILER === 'smtp' && defined( 'WPMS_SSL' ) && defined( 'WPMS_SMTP_HOST' ) && defined( 'WPMS_SMTP_PORT' ) ) { $phpmailer->SMTPSecure = WPMS_SSL; $phpmailer->Host = WPMS_SMTP_HOST; $phpmailer->Port = WPMS_SMTP_PORT; if ( defined( 'WPMS_SMTP_AUTH' ) && WPMS_SMTP_AUTH && defined( 'WPMS_SMTP_USER' ) && defined( 'WPMS_SMTP_PASS' ) ) { $phpmailer->SMTPAuth = true; $phpmailer->Username = WPMS_SMTP_USER; $phpmailer->Password = WPMS_SMTP_PASS; } } } else { $option_mailer = get_option( 'mailer' ); $option_smtp_host = get_option( 'smtp_host' ); $option_smtp_ssl = get_option( 'smtp_ssl' ); // Check that mailer is not blank, and if mailer=smtp, host is not blank. if ( ! $option_mailer || ( 'smtp' === $option_mailer && ! $option_smtp_host ) ) { return; } // If the mailer is pepipost, make sure we have a username and password. if ( 'pepipost' === $option_mailer && ( ! get_option( 'pepipost_user' ) && ! get_option( 'pepipost_pass' ) ) ) { return; } // Set the mailer type as per config above, this overrides the already called isMail method. $phpmailer->Mailer = $option_mailer; // Set the Sender (return-path) if required. if ( get_option( 'mail_set_return_path' ) ) { $phpmailer->Sender = $phpmailer->From; } // Set the SMTPSecure value, if set to none, leave this blank. $phpmailer->SMTPSecure = $option_smtp_ssl; if ( 'none' === $option_smtp_ssl ) { $phpmailer->SMTPSecure = ''; $phpmailer->SMTPAutoTLS = false; } // If we're sending via SMTP, set the host. if ( 'smtp' === $option_mailer ) { // Set the other options. $phpmailer->Host = $option_smtp_host; $phpmailer->Port = get_option( 'smtp_port' ); // If we're using smtp auth, set the username & password. if ( get_option( 'smtp_auth' ) === 'true' ) { $phpmailer->SMTPAuth = true; $phpmailer->Username = get_option( 'smtp_user' ); $phpmailer->Password = get_option( 'smtp_pass' ); } } elseif ( 'pepipost' === $option_mailer ) { // Set the Pepipost settings. $phpmailer->Mailer = 'smtp'; $phpmailer->Host = 'smtp.pepipost.com'; $phpmailer->Port = get_option( 'pepipost_port' ); $phpmailer->SMTPSecure = get_option( 'pepipost_ssl' ) === 'none' ? '' : get_option( 'pepipost_ssl' ); $phpmailer->SMTPAuth = true; $phpmailer->Username = get_option( 'pepipost_user' ); $phpmailer->Password = get_option( 'pepipost_pass' ); } } // You can add your own options here, see the phpmailer documentation for more info: http://phpmailer.sourceforge.net/docs/. /** @noinspection PhpUnusedLocalVariableInspection It's passed by reference. */ $phpmailer = apply_filters( 'wp_mail_smtp_custom_options', $phpmailer ); } endif; if ( ! function_exists( 'wp_mail_smtp_options_page' ) ) : /** * This function outputs the plugin options page. */ function wp_mail_smtp_options_page() { global $phpmailer; // Make sure the PHPMailer class has been instantiated // (copied verbatim from wp-includes/pluggable.php) // (Re)create it, if it's gone missing. if ( ! is_object( $phpmailer ) || ! is_a( $phpmailer, 'PHPMailer' ) ) { require_once ABSPATH . WPINC . '/class-phpmailer.php'; $phpmailer = new PHPMailer( true ); } // Send a test mail if necessary. if ( isset( $_POST['wpms_action'] ) && esc_html__( 'Send Test', 'wp-mail-smtp' ) === sanitize_text_field( $_POST['wpms_action'] ) && is_email( $_POST['to'] ) ) { check_admin_referer( 'test-email' ); // Set up the mail variables. $to = sanitize_text_field( $_POST['to'] ); /* translators: %s - email address where test mail will be sent to. */ $subject = 'WP Mail SMTP: ' . sprintf( esc_html__( 'Test mail to %s', 'wp-mail-smtp' ), $to ); $message = esc_html__( 'This is a test email generated by the WP Mail SMTP WordPress plugin.', 'wp-mail-smtp' ); // Set SMTPDebug level, default is 2 (commands + data + connection status). $phpmailer->SMTPDebug = apply_filters( 'wp_mail_smtp_admin_test_email_smtp_debug', 2 ); // Start output buffering to grab smtp debugging output. ob_start(); // Send the test mail. $result = wp_mail( $to, $subject, $message ); // Grab the smtp debugging output. $smtp_debug = ob_get_clean(); // Output the response. ?>
' . sprintf( /* translators: %1$s - WP Mail SMTP plugin name; %2$s - opening a link tag; %3$s - closing a link tag. */ esc_html__( 'Your site is running an outdated version of PHP that is no longer supported and may cause issues with %1$s. %2$sRead more%3$s for additional information.', 'wp-mail-smtp' ), 'WP Mail SMTP', '', '' ) . '
' . '