From ad43e637bd51b5b288856fee9a69da851ba07779 Mon Sep 17 00:00:00 2001 From: thomascube Date: Tue, 26 Feb 2008 18:08:19 +0000 Subject: Add SMTP test to installer script --- installer/test.php | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) (limited to 'installer/test.php') diff --git a/installer/test.php b/installer/test.php index b782a5c44..0f499eba3 100644 --- a/installer/test.php +++ b/installer/test.php @@ -123,7 +123,72 @@ if ($db_working) { ?> -

[@todo Add tests for IMAP and SMTP settings]

+

Test SMTP settings

+ +

+Server: getprop('smtp_server', 'PHP mail()'); ?>
+Port: getprop('smtp_port'); ?>
+User: getprop('smtp_user', '(none)'); ?>
+Password: getprop('smtp_pass', '(none)'); ?>
+

+ +Trying to send email...
'; + + if (preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_from'])) && + preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_to']))) { + + $recipients = trim($_POST['_to']); + + $headers = array( + 'From' => trim($_POST['_from']), + 'To' => $recipients, + 'Subject' => 'Test message from RoundCube', + ); + + $body = 'This is a test to confirm that RoundCube can send email.'; + + $mail_object = new rc_mail_mime(); + $send_headers = $mail_object->headers($headers); + + $smtp_response = array(); + $status = smtp_mail($headers['From'], $recipients, + ($foo = $mail_object->txtHeaders($send_headers)), + $body, $smtp_response); + + if ($status) { + $RCI->pass('SMTP send'); + } + else { + $RCI->fail('SMTP send', join('; ', $smtp_response)); + } + } + else { + $RCI->fail('SMTP send', 'Invalid sender or recipient'); + } +} + +echo '

'; + +?> + + + + + + +
+ +

+ + +

[@todo Add tests for IMAP settings]

-- cgit v1.2.3