// ###################### Start mail test #######################
if ($_POST['do'] == 'domail')
{
$vbulletin->input->clean_array_gpc('p', array(
'emailaddress' => TYPE_STR,
));
print_form_header('', '');
if ($vbulletin->options['use_smtp'])
{
print_table_header($vbphrase['pertinent_smtp_settings']);
print_label_row('SMTP:', (!empty($vbulletin->options['smtp_tls']) ? 'tls://' : '') . $vbulletin->options['smtp_host'] . ':' . (!empty($vbulletin->options['smtp_port']) ? intval($vbulletin->options['smtp_port']) : 25));
print_label_row($vbphrase['smtp_username'], $vbulletin->options['smtp_user']);
}
else
{
print_table_header($vbphrase['pertinent_php_settings']);
print_label_row('SMTP:', iif($SMTP = @ini_get('SMTP'), $SMTP, '<i>' . $vbphrase['none'] . '</i>'));
print_label_row('sendmail_from:', iif($sendmail_from = @ini_get('sendmail_from'), $sendmail_from, '<i>' . $vbphrase['none'] . '</i>'));
print_label_row('sendmail_path:', iif($sendmail_path = @ini_get('sendmail_path'), $sendmail_path, '<i>' . $vbphrase['none'] . '</i>'));
}
print_table_footer();
$emailaddress = $vbulletin->GPC['emailaddress'];
if (empty($emailaddress))
{
print_diagnostic_test_result(0, $vbphrase['please_complete_required_fields']);
}
if (!is_valid_email($emailaddress))
{
print_diagnostic_test_result(0, $vbphrase['invalid_email_specified']);
}
$subject = ($vbulletin->options['needfromemail'] ? $vbphrase['vbulletin_email_test_withf'] : $vbphrase['vbulletin_email_test']);
$message = construct_phrase($vbphrase['vbulletin_email_test_msg'], $vbulletin->options['bbtitle']);
if (!class_exists('vB_Mail'))
{
require_once(DIR . '/includes/class_mail.php');
}
if ($vbulletin->options['use_smtp'])
{
$mail =& new vB_SmtpMail($vbulletin);
}
else
{
$mail =& new vB_Mail($vbulletin);
}
$mail->set_debug(true);
$mail->start($emailaddress, $subject, $message, $vbulletin->options['webmasteremail']);
// error handling
@ini_set('display_errors', true);
if (strpos(@ini_get('disable_functions'), 'ob_start') !== false)
{
// alternate method in case OB is disabled; probably not as fool proof
@ini_set('track_errors', true);
$oldlevel = error_reporting(0);
}
else
{
ob_start();
}
$mailreturn = $mail->send();
if (strpos(@ini_get('disable_functions'), 'ob_start') !== false)
{
error_reporting($oldlevel);
$errors = $php_errormsg;
}
else
{
$errors = ob_get_contents();
ob_end_clean();
}
// end error handling
if (!$mailreturn OR $errors)
{
$results = array();
if (!$mailreturn)
{
$results[] = $vbphrase['mail_function_returned_error'];
}
if ($errors)
{
$results[] = $vbphrase['mail_function_errors_returned_were'].'<br /><br />' . $errors;
}
if (!$vbulletin->options['use_smtp'])
{
$results[] = $vbphrase['check_mail_server_configured_correctly'];
}
print_diagnostic_test_result(0, $results);
}
else
{
print_diagnostic_test_result(1, construct_phrase($vbphrase['email_sent_check_shortly'], $emailaddress));
}
}