function open_mailbox($auth_user, $accountid) { global $HTTP_SESSION_VARS; // select mailbox if there is only one if (number_of_accounts($auth_user) == 1) { $accounts = get_account_list($auth_user); $HTTP_SESSION_VARS['selected_account'] = $accounts[0]; $accountid = $accounts[0]; } // connect to the POP3 or IMAP server the user has selected $settings = get_account_settings($auth_user, $accountid); if (!sizeof($settings)) { return 0; } $mailbox = '{' . $settings[server]; if ($settings[type] == 'POP3') { $mailbox .= '/pop3'; } $mailbox .= ':' . $settings[port] . '}INBOX'; // suppress warning, remember to check return value @($imap = imap_open($mailbox, $settings['remoteuser'], $settings['remotepassword'])); return $imap; }
function display_list($auth_user, $accountid) { // echo "Debug: display_list()<br />"; global $table_width; //debug $accountid -> $accountid[0] $counter = 0; // echo "Debug: counter: ".$counter."<br />"; if (!$accountid) { echo "<p style=\"padding-bottom: 100px\">Mailbox is not selected.</p>"; } else { $imap = open_mailbox($auth_user, $accountid); if ($imap) { echo "<table width=\"" . $table_width . "\" cellspacing=\"0\"\n cellpadding=\"6\" border=\"0\">"; $headers = imap_headers($imap); $messages = sizeof($headers); for ($i = 0; $i < $messages; $i++) { echo "<tr><td bgcolor=\""; if ($i % 2) { echo '#ffffff'; } else { echo '#ffffcc'; } echo "\"><a href=\"index.php?action=view-message&messageid=" . ($i + 1) . "\">"; echo $headers[$i]; echo "</a></td></tr>\n"; } echo "</table>"; } else { $account = get_account_settings($auth_user, $accountid); echo "<p style=\"padding-bottom: 100px\">Can\\'t open mailbox" . $account['server'] . ".</p>"; } } }
function display_account_select($auth_user, $selected_account) { // show the dropdown box for the user to select from their accounts $list = get_account_list($auth_user); $accounts = sizeof($list); if ($accounts > 1) { echo "<select onchange=\"window.location=this.options[selectedIndex].value name=account\">"; if ($selected_account == '') { echo "<option value=\"0\" selected>Choose Account</a>"; } for ($i = 0; $i < $accounts; $i++) { $account = get_account_settings($auth_user, $list[$i]); echo "<option value=\"index.php?action=select-account&account=" . $list[$i] . "\""; if ($list[$i] == $selected_account) { echo " selected"; } echo ">" . $account['server'] . "</option>"; } echo "</select>"; } }
function open_mailbox($auth_user, $accountid) { // echo "Debug: open_mailbox()<br />"; if (number_of_accounts($auth_user) == 1) { $accounts = get_account_list($auth_user); $_SESSION['selected_account'] = $accounts[0]; $accountid = $accounts[0]; } $settings = get_account_settings($auth_user, $accountid); // echo "Debug: settings[server]: ".$settings['server']."<br />"; if (!sizeof($settings)) { return 0; } $mailbox = '{' . $settings['server']; if ($settings['type'] == 'POP3') { $mailbox .= '/pop3'; } $mailbox .= ':' . $settings['port'] . '/ssl}INBOX'; // echo "mailbox: ".$mailbox."<br />"; $imap = imap_open($mailbox, $settings['remoteuser'], $settings['remotepassword']); return $imap; }