- Products
- Purchase
Order Online Maintenance Renewal Resellers - Support
Helpdesk Online Documentation Web Forum - Our Clients
- About
About us Services Contact
From AfterLogic Wiki
Introduction
You may need to make WebMail interface a part of your web site interface.
For example, if your web site has several sections (e.g. "My Blog", "My Pictures", "My Mail") and a navigation menu which should always stay on the screen (no matter which section is currently selected), WebMail shouldn't overlap the navigation menu and shouldn't be opened in a separate window.
To achieve this, you need to place WebMail into an IFRAME which is a part of your interface. Placing WebMail directly into your interface (e.g. into a DIV element) is not possible as it's complex AJAX application which relies to absolute coordinates and has its own system of exchanging XML packets with server. So, an IFRAME is the only way to get it working properly.
Simple placing WebMail into your interface
The following example demonstrates how to place WebMail into an IFRAME:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" /> <html> <head> <title>iframe test</title> </head> <body> <div style="background-color: #EEE; width: 900px;">Your navigation menu here</div><br /> <iframe src="http://webmail.mailstone.net/" style="width: 900px; height: 600px;"></iframe> </body> </html>
Here, you can see http://webmail.mailstone.net/. It points to AfterLogic WebMail Pro PHP live demo at our web site. You should change this URL to the one pointing to your WebMail installation.
Placing WebMail into your interface along with passing authentication data
Now let's use visual integration along with passing authentication data to WebMail which is described here. First, please create test-iframe.php file and copy/paste the code from Logging in programmatically section there, then modify the example to get it working in your environment. It's assumed that you placed that file into the integration subfolder of your WebMail installation. The code will be slightly modified (see below).
Now, just add the following line to one of your PHP pages:
<iframe src="webmail/integration/test-iframe.php" style="width: 900px; height: 600px;"></iframe>Now, you may wonder how to pass authentication data from your PHP application to LoginToAccount method called in test-iframe.php. We won't pass those data through POST method, server-side PHP sessions are used instead. Example:
- index.php file:
<?php session_start(); // Store credentials in session $_SESSION['email'] = 'john_doe@mydomain.com'; $_SESSION['password'] = 'mypassword'; ?> <iframe src="webmail/integration/test-iframe.php" style="width: 900px; height: 600px;"></iframe></nowiki></span>
- webmail/integration/test-iframe.php file:
<?php // Example of logging into WebMail account using email and password for incorporating into another web application // determining main directory defined('WM_ROOTPATH') || define('WM_ROOTPATH', (dirname(__FILE__).'/../')); // utilizing WebMail Pro API include_once WM_ROOTPATH.'libraries/afterlogic/api.php'; if (class_exists('CApi') && CApi::IsValid()) { // data for logging into account $sEmail = $_SESSION['email']; $sPassword = $_SESSION['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'; }
Last edit: 2011/5/12