Sender if true define('WPMS_SMTP_HOST', 'localhost'); // The SMTP mail host define('WPMS_SMTP_PORT', 25); // The SMTP server port number define('WPMS_SSL', ''); // Possible values '', 'ssl', 'tls' - note TLS is not STARTTLS define('WPMS_SMTP_AUTH', true); // True turns on SMTP authentication, false turns it off define('WPMS_SMTP_USER', 'username'); // SMTP authentication username, only used if WPMS_SMTP_AUTH is true define('WPMS_SMTP_PASS', 'password'); // SMTP authentication password, only used if WPMS_SMTP_AUTH is true */ /** * Newer PHP version 5.3+ will be handled a lot differently, * with better code and newer logic. * * @since 1.0.0 */ if ( version_compare( phpversion(), WPMS_PHP_VER, '>=' ) ) { require_once dirname( __FILE__ ) . '/wp-mail-smtp.php'; return; } /** * Array of options and their default values. * This is horrible, should be cleaned up at some point. */ global $wpms_options; $wpms_options = array( 'mail_from' => '', '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', 'wp_mail_smtp_am_notifications_hidden' => '', ); /** * 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. ?>

' ); _e( 'Please Note: You appear to be using a version of WordPress prior to 2.3. Please ignore the From Name field and instead enter Name<email@domain.com> in this field.', 'wp-mail-smtp' ); print( '' ); } ?>

/>

/>

/>

', '' ); ?>

/>
/>
/>

/>
/>

Pepipost', '' ); ?>

/>
/>
/>

' . esc_html__( 'Settings', 'wp-mail-smtp' ) . ''; array_unshift( $links, $settings_link ); return $links; } /** * Awesome Motive Notifications. * * @since 0.11 */ function wp_mail_smtp_am_notifications() { $is_hidden = get_option( 'wp_mail_smtp_am_notifications_hidden', '' ); if ( 'true' === $is_hidden ) { return; } if ( ! class_exists( 'WPMS_AM_Notification' ) ) { require_once dirname( __FILE__ ) . '/class-wpms-am-notification.php'; } new WPMS_AM_Notification( 'smtp', WPMS_PLUGIN_VER ); } add_action( 'plugins_loaded', 'wp_mail_smtp_am_notifications' ); /** * Check whether the site is using Pepipost or not. * * @since 0.11 * * @return bool */ function wp_mail_smtp_is_pepipost_active() { return apply_filters( 'wp_mail_smtp_options_is_pepipost_active', 'pepipost' === get_option( 'mailer' ) ); } /** * Check the current PHP version and display a notice if on unsupported PHP. * * @since 0.11 */ function wp_mail_smtp_check_php_version() { // Display for PHP below 5.3. if ( version_compare( PHP_VERSION, '5.3.0', '>=' ) ) { return; } // Display for admins only. if ( ! is_super_admin() ) { return; } // Display on Dashboard page only. if ( isset( $GLOBALS['pagenow'] ) && 'index.php' !== $GLOBALS['pagenow'] ) { return; } echo '
' . '

' . 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.', 'wpforms' ), 'WP Mail SMTP', '', '' ) . '

' . '
'; } add_action( 'admin_notices', 'wp_mail_smtp_check_php_version' ); // Add an action on phpmailer_init. add_action( 'phpmailer_init', 'phpmailer_init_smtp' ); if ( ! defined( 'WPMS_ON' ) || ! WPMS_ON ) { // Whitelist our options. add_filter( 'whitelist_options', 'wp_mail_smtp_whitelist_options' ); // Add the create pages options. add_action( 'admin_menu', 'wp_mail_smtp_menus' ); // Add an activation hook for this plugin. register_activation_hook( __FILE__, 'wp_mail_smtp_activate' ); // Adds "Settings" link to the Plugins page. add_filter( 'plugin_action_links', 'wp_mail_plugin_action_links', 10, 2 ); } // Add filters to replace the mail from name and email address. add_filter( 'wp_mail_from', 'wp_mail_smtp_mail_from' ); add_filter( 'wp_mail_from_name', 'wp_mail_smtp_mail_from_name' ); load_plugin_textdomain( 'wp-mail-smtp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );