';
if ( $this->result === self::FAILED_DOMAIN_CHECK ) {
$this->display_domain_check_details();
} elseif ( $this->result === self::FAILED ) {
$this->display_debug_details();
}
echo '
';
?>
check_admin_referer();
$this->post_data = $data;
$connection = easy_wp_smtp()->get_connections_manager()->get_primary_connection();
/**
* Filters test email connection object.
*
* @since 2.0.0
*
* @param ConnectionInterface $connection The Connection object.
* @param array $data Post data.
*/
$this->connection = apply_filters( 'easy_wp_smtp_admin_pages_test_tab_process_post_connection', $connection, $data );
if ( ! empty( $data['test']['email'] ) ) {
$data['test']['email'] = wp_unslash( $data['test']['email'] );
$data['test']['email'] = filter_var( $data['test']['email'], FILTER_VALIDATE_EMAIL );
}
$is_html = true;
if ( empty( $data['test']['html'] ) ) {
$is_html = false;
}
if ( empty( $data['test']['email'] ) ) {
WP::add_admin_notice(
esc_html__( 'Test failed. Please use a valid email address and try to resend the test email.', 'easy-wp-smtp' ),
WP::ADMIN_NOTICE_WARNING
);
return;
}
$phpmailer = easy_wp_smtp()->get_processor()->get_phpmailer();
// Set SMTPDebug level, default is 3 (commands + data + connection status).
$phpmailer->SMTPDebug = apply_filters( 'easy_wp_smtp_admin_test_email_smtp_debug', 3 );
if ( $is_html ) {
add_filter( 'wp_mail_content_type', array( __CLASS__, 'set_test_html_content_type' ) );
}
$to = $data['test']['email'];
if ( ! empty( $data['test']['custom'] ) && ! empty( $data['test']['subject'] ) ) {
$subject = $data['test']['subject'];
} else {
if ( $is_html ) {
/* translators: %s - email address a test email will be sent to. */
$subject = 'Easy WP SMTP: HTML ' . sprintf( esc_html__( 'Test email to %s', 'easy-wp-smtp' ), $data['test']['email'] );
} else {
/* translators: %s - email address a test email will be sent to. */
$subject = 'Easy WP SMTP: ' . sprintf( esc_html__( 'Test email to %s', 'easy-wp-smtp' ), $data['test']['email'] );
}
}
$headers = [ 'X-Mailer-Type:EasyWPSMTP/Admin/Test' ];
if ( $is_html ) {
$headers[] = 'Content-Type: text/html';
}
// Clear debug before send test email.
Debug::clear();
// Force processing for test email even if email sending is blocked.
easy_wp_smtp()->get_processor()->set_force_processing( true );
// Start output buffering to grab smtp debugging output.
ob_start();
// Send the test mail.
$result = wp_mail(
$to,
$subject,
$this->get_email_message( $is_html ),
$headers
);
$smtp_debug = ob_get_clean();
easy_wp_smtp()->get_processor()->set_force_processing( false );
if ( $is_html ) {
remove_filter( 'wp_mail_content_type', array( __NAMESPACE__, 'set_test_html_content_type' ) );
}
/*
* Notify a user about the results.
*/
if ( $result ) {
$connection_options = $this->connection->get_options();
$mailer = $connection_options->get( 'mail', 'mailer' );
$email = $connection_options->get( 'mail', 'from_email' );
$domain = '';
// Add the optional sending domain parameter.
if ( in_array( $mailer, [ 'mailgun', 'sendinblue', 'sendgrid' ], true ) ) {
$domain = $connection_options->get( $mailer, 'domain' );
}
$this->domain_checker = new DomainChecker( $mailer, $email, $domain );
$this->result = $this->domain_checker->no_issues() ? self::SUCCESS : self::FAILED_DOMAIN_CHECK;
if ( $this->result === self::SUCCESS ) {
$result_message = esc_html__( 'Test plain text email was sent successfully!', 'easy-wp-smtp' );
if ( $is_html ) {
$result_message = sprintf(
/* translators: %s - "HTML" in bold. */
esc_html__( 'Test %s email was sent successfully! Please check your inbox to make sure it is delivered.', 'easy-wp-smtp' ),
'
Thank you for using Easy WP SMTP. We're on a mission to make sure your emails actually get delivered.
Jared Atchison
CEO, SendLayer
|
is_pro() ) : ?>
Unlock Powerful Features with Easy WP SMTP Pro
|
Detailed Email Logs
|
|
Complete Email Reports
|
|
Enhanced Weekly Email Summary
|
|
|
|
|
is_pro() ) {
// Easy WP SMTP Pro paid installed.
$message =
'Congrats, test email was sent successfully!
Thank you for using Easy WP SMTP. We\'re on a mission to make sure your emails actually get delivered.
- Jared Atchison
CEO, SendLayer';
} else {
// Free Easy WP SMTP is installed.
$message =
'Congrats, test email was sent successfully!
Thank you for trying out Easy WP SMTP. We are on a mission to make sure your emails actually get delivered.
If you find this free plugin useful, please consider giving Easy WP SMTP Pro a try!
https://easywpsmtp.com/lite-upgrade/
Unlock These Powerful Features with Easy WP SMTP Pro:
+ Log all emails and export your email logs in different formats
+ Send emails with Amazon SES / Microsoft 365/ Zoho Mail
+ Track opens and clicks to measure engagement
+ Resend failed emails from your email log
+ Create email reports and graphs
+ Get help from our world-class support team
- Jared Atchison
CEO, SendLayer';
}
// phpcs:enable
return $message;
}
/**
* Set the HTML content type for a test email.
*
* @since 2.0.0
*
* @return string
*/
public static function set_test_html_content_type() {
return 'text/html';
}
/**
* Prepare debug information, that will help users to identify the error.
*
* @since 2.0.0
*
* @param MailCatcherInterface $phpmailer The MailCatcher object.
* @param string $smtp_debug The SMTP debug message.
*
* @return string
*/
protected function get_debug_messages( $phpmailer, $smtp_debug ) {
$connection_options = $this->connection->get_options();
$conflicts = new Conflicts();
$this->debug['mailer'] = $connection_options->get( 'mail', 'mailer' );
/*
* Versions Debug.
*/
$versions_text = '
' . $description . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
echo $description; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
?>
is_pro() ) : ?>
submit a support ticket.', 'easy-wp-smtp' ),
array(
'a' => array(
'href' => array(),
'rel' => array(),
'target' => array(),
),
)
),
// phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
esc_url( easy_wp_smtp()->get_utm_url( 'https://easywpsmtp.com/account/support/', [ 'medium' => 'email-test', 'content' => 'submit a support ticket' ] ) )
);
?>
upgrade to Easy WP SMTP Pro. Along with getting expert support, you will also get Notification controls, Email Logging, and integrations for Amazon SES, Office 365, and Outlook.com.', 'easy-wp-smtp' ),
array(
'a' => array(
'href' => array(),
'target' => array(),
'rel' => array(),
),
)
),
esc_url( easy_wp_smtp()->get_upgrade_link( 'email-test-fail' ) )
)
?>
%s off regular pricing, automatically applied at checkout!', 'easy-wp-smtp' ),
array(
'span' => array(
'class' => array(),
),
)
),
'50%'
);
?>
create a support thread there, but please understand that free support is not guaranteed and is limited to simple issues. If you have an urgent or complex issue, then please consider upgrading to Easy WP SMTP Pro to access our priority support ticket system.', 'easy-wp-smtp' ),
array(
'a' => array(
'href' => array(),
'rel' => array(),
'target' => array(),
),
)
),
'https://wordpress.org/support/plugin/easy-wp-smtp/',
esc_url( easy_wp_smtp()->get_upgrade_link( 'email-test-fail' ) )
);
?>
debug['error_log'], $allowed_tags ); ?>
domain_checker ) || $this->domain_checker->no_issues() ) {
return;
}
?>
domain_checker->is_supported_mailer() ) : ?>