is_action('test')) {
if (!NewsletterModule::is_email($controls->data['test_email'])) {
$controls->errors = 'The test email address is not set or is not correct.';
}
if (empty($controls->errors)) {
$options = $controls->data;
if ($controls->data['test_email'] == $this->options['sender_email']) {
$controls->messages .= 'Warning: you are using as test email the same address configured as sender in main configuration. Test can fail because of that.
';
}
$message = new TNP_Mailer_Message();
$message->body = '
This is an HTML test email sent using the sender data set on Newsletter main setting. This is a link to an external site.
';
$message->body_text = 'This is a textual test email part sent using the sender data set on Newsletter main setting.';
$message->to = $controls->data['test_email'];
$message->subject = 'Newsletter test email at ' . date(DATE_ISO8601);
$message->from = $this->options['sender_email'];
$message->from_name = $this->options['sender_name'];
$r = $this->deliver($message);
if (!is_wp_error($r)) {
$options['mail'] = 1;
$controls->messages .= 'SUCCESS
';
$controls->messages .= 'Anyway if the message does not appear the mailbox (check even the spam folder) you can ';
$controls->messages .= 'read more here.';
} else {
$options['mail'] = 0;
$options['mail_error'] = $r->get_error_message();
$controls->errors .= 'FAILED (' . $r->get_error_message() . ')
';
if (!empty($this->options['return_path'])) {
$controls->errors .= '- Try to remove the return path on main settings.
';
}
$controls->errors .= '' . __('Read more', 'newsletter') . '.';
$parts = explode('@', $this->options['sender_email']);
$sitename = strtolower($_SERVER['SERVER_NAME']);
if (substr($sitename, 0, 4) == 'www.') {
$sitename = substr($sitename, 4);
}
if (strtolower($sitename) != strtolower($parts[1])) {
$controls->errors .= '- Try to set on main setting a sender address with the same domain of your blog: ' . $sitename . ' (you are using ' . $this->options['sender_email'] . ')
';
}
}
$this->save_options($options, 'status');
}
}
if ($controls->is_action('optimize-stats')) {
$this->logger->info('Stats table otpimization');
$this->query("alter table " . NEWSLETTER_STATS_TABLE . " drop index email_id");
$this->query("alter table " . NEWSLETTER_STATS_TABLE . " drop index user_id");
$this->query("alter table `" . NEWSLETTER_STATS_TABLE . "` modify column `email_id` int(11) not null default 0");
$this->query("create index email_id on " . NEWSLETTER_STATS_TABLE . " (email_id)");
$this->query("create index user_id on " . NEWSLETTER_STATS_TABLE . " (user_id)");
$controls->add_message_done();
}
$options = $this->get_options('status');
?>