9f0603cf8f405a07f62ab7861d58a4be89e0886c
4 * mailto.php -- mailto: url handler
6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This checks to see if we're logged in. If we are we open up a new
10 * compose window for this email, otherwise we go to login.php
11 * (the above functionality has been disabled, by default you are required to
14 * Use the following url to use mailto:
15 * http://<your server>/<squirrelmail base dir>/src/mailto.php?emailaddress="%1"
16 * see ../contrib/squirrelmail.mailto.reg for a Windows Registry file
19 /* Path for SquirrelMail required files. */
20 define('SM_PATH','../');
22 /* SquirrelMail required files. */
23 require_once(SM_PATH
. 'config/config.php');
24 require_once(SM_PATH
. 'functions/global.php');
26 header('Pragma: no-cache');
27 if(!sqgetGlobalVar('emailaddress', $emailaddress)) {
31 if(stristr($emailaddress, 'mailto:')) {
32 $emailaddress = substr($emailaddress, 7);
34 if(($pos = strpos($emailaddress, '?')) !== false) {
35 $a = substr($emailaddress, $pos+
1);
36 list($emailaddress, $a) = explode('?', $emailaddress, 2);
37 $a = explode('=', $a, 2);
38 $_GET['emailaddress'] = $emailaddress;
42 $trtable = array('emailaddress' => 'send_to',
44 'bcc' => 'send_to_bcc',
46 'subject' => 'subject');
48 /* CC, BCC, etc could be any case, so we'll fix them here */
49 foreach($_GET as $k=>$g) {
53 $url .= $k . '=' . urlencode($g) . '&';
56 $url = substr($url, 0, -1);
58 sqsession_is_active();
59 /* Check to see if we're logged in */
61 if (sqsession_is_registered('user_is_logged_in')) {
62 $redirect = 'webmail.php?right_frame=compose.php?';
64 $redirect = 'login.php?mailto=';
67 $url = urlencode($url);
68 /* $redirect .= $url; */
69 $redirect = 'login.php?mailto=' . $url;
70 session_write_close();
71 header('Location: ' . $redirect);