<?php
/**
* This small script makes it possible to test whether the
* RoundcubeLogin-class works as expected.
*
* Please find a detailed description of the available functions
* in the original blog post:
*
* http://blog.philippheckel.com/2008/05/16/roundcube-login-via-php-script/
* Updated July 2013
*/
include "RoundcubeLogin.class.php";
// Set to TRUE if something doesn't work
$debug = true;
$rcPath = "/roundcubemail-0.9.2/";
// Pass the relative Roundcube path to the constructor
$rcl = new RoundcubeLogin($rcPath, $debug);
// $rcl->setHostname("example.localhost");
// $rcl->setPort(443);
// $rcl->setSSL(true);
try {
// Perform login/logout action
if ($_GET['action'] == "login")
$rcl->login("your-email-address", "plain-text-password");
else if ($_GET['action'] == "logout")
$rcl->logout();
// Get current status
if ($rcl->isLoggedIn())
$status = "We are logged in!";
else
$status = "We're NOT logged in.";
}
catch (RoundcubeLoginException $ex) {
// If anything goes wrong, an exception is thrown.
$status = "ERROR: ".$ex->getMessage();
}
// Output / Controls
echo "Status: $status<br />";
echo "<a href='rclogin.php'>Status</a> - <a href='rclogin.php?action=login'>Login</a> - ";
echo "<a href='rclogin.php?action=logout'>Logout</a><br />";
$rcl->dumpDebugStack();
?>