Search The ForumSearch   RegisterRegister  LoginLogin

AfterLogic WebMail Lite 7

 AfterLogic Forum : AfterLogic WebMail Lite 7
Subject Topic: API login Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
thbthb
Newbie
Newbie
Avatar

Joined: 31 October 2011
Location: Norway
Online Status: Offline
Posts: 3
Posted: 01 November 2011 at 2:01am | IP Logged Quote thbthb

Hi,

I just set up hmailserver and I'm trying to get the autologon via API to work. I am able to login manually, but the programmatically way does not work.

I'm transfered to webmail/index.php?error=2 after script load.
If I am already logged in and run the script, it works perfectly.

This is my script:

include_once WM_ROOTPATH.'libraries/afterlogic/api.php';
if (class_exists('CApi') && CApi::IsValid())
{
// data for logging into account
$sEmail = 'test@domain';
$sPassword = 'password';

// Getting required API class
$oApiWebMailManager = CApi::Manager('webmail');

// attempting to obtain object for account we're trying to log into
$oAccount = $oApiWebMailManager->LoginToAccount($sEmail, $sPassword);
if ($oAccount)
{
    // populating session data from the account
    $oAccount->FillSession();

    // redirecting to WebMail
    $oApiWebMailManager->JumpToWebMail('webmail.php?check=1');
}
else
{
    // login error
    echo $oApiWebMailManager->GetLastErrorMessage();
}
}
else
{
echo 'WebMail API not allowed';
}

According to the debug log in both cases the login to the IMAP is successful.
Why am I unable to log in?

thanks
Back to Top View thbthb's Profile Search for other posts by thbthb
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 01 November 2011 at 3:19am | IP Logged Quote Igor

Is the script located in WebMail directory? If not, you'll need to supply proper URL for webmail.php in JumpToWebMail method call.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
thbthb
Newbie
Newbie
Avatar

Joined: 31 October 2011
Location: Norway
Online Status: Offline
Posts: 3
Posted: 01 November 2011 at 1:00pm | IP Logged Quote thbthb

Hi,

The script is in the same directory as webmail.php. webmail.php is loaded, but the error The account doesn't exist, perhaps, it has just been deleted. is shown.
Back to Top View thbthb's Profile Search for other posts by thbthb
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 02 November 2011 at 12:58am | IP Logged Quote Igor

Looks like something related to cookies or session, or maybe account authentication details. If you manage to find what's causing this, feel free to share your experience.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide